I am looking for the code in visual basic to calculate the radio button that is
ID: 3875042 • Letter: I
Question
I am looking for the code in visual basic to calculate the radio button that is selected x the number of nights selected (this can be 1 - 10 nights) sent to the web form called [lblReservation}
A reservation has been made for Name
The total cost to stay at (selected city's name if possible) is $XX.XX
Arrival Date is x/x/x for x Night(s).
Below is my current code:
Partial Class _Default
Inherits Page
Protected Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
Dim strName As String
'Dim intNumberofNights As Integer
' Trim additional spaces that are entered by the user
strName = txtName.Text.Trim
lblReservation.Text = ""
If ddlNights.SelectedIndex.Equals(0) Then
lblNIghtsError.Visible = True
Else
lblNIghtsError.Visible = False
If cldDates.SelectedDate < cldDates.TodaysDate Then
lblCalendarError.Visible = True
Else
lblCalendarError.Visible = False
End If
End If
' This will show the Calendar error if valid date not selected.
If cldDates.SelectedDate < cldDates.TodaysDate Then
lblCalendarError.Visible = True
End If
' Calculate the cost of the room
End Sub
Protected Sub radCity_SelectedIndexChanged(sender As Object, e As EventArgs) Handles radCity.SelectedIndexChanged
End Sub
Protected Sub cldDates_SelectionChanged(sender As Object, e As EventArgs) Handles cldDates.SelectionChanged
End Sub
Protected Sub ddlNights_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlNights.SelectedIndexChanged
End Sub
Protected Sub txtName_TextChanged(sender As Object, e As EventArgs) Handles txtName.TextChanged
End Sub
End Class
Response:
I am trying to achieve the below screenshot for when I hit the submit button on my webform. It will take and calculate the room selected from one of the 3 radio buttons x the number of nights select. The number of nights can be between 1 to 10 nights. It would then take that information and add it to my web form for under the label lblReservation that is on the screenshot above.. Hopefully that makes sense.
Listitem Collection Editor Enter Name RadioButtonList Tasks Choose Data Source... Edit Items... asp:RadioButtonL Edinburgh ($17 a night) Members: Edinburgh (S17 a night) properties: Edinburgh ($17 a night) 1 Florence ($23 value) 2 Barcelona ($19 a night) C Florence ($23 value) v Misc Barcelona ($19 a night) Enable AutoPostBack Enabled Selected Text Value True False Edinburgh ($17 a night) 17 Select Night January 2018 Submit 31 1 23 4 56 * Select a valid Date 7 8910 12 13 IblReservation] 14 15 16 17 18 19 20Explanation / Answer
I hope you will change in VB:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CheggQS
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
lblFixd.Text = "Book Our Youth Hostels";
comboBox1.Items.AddRange(Enumerable.Range(1, 10).Select(i => (object)i).ToArray());
}
private void txtName_TextChanged(object sender, EventArgs e)
{
}
private void rdbEdinburg_CheckedChanged(object sender, EventArgs e)
{
}
private void rdbFlorence_CheckedChanged(object sender, EventArgs e)
{
}
private void rdbBacelona_CheckedChanged(object sender, EventArgs e)
{
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
}
private void btnSubmit_Click(object sender, EventArgs e)
{
try
{
string nameOfCustomer = txtName.Text.Trim();
int totalNights = 0;
string str = comboBox1.Text;
string arrivalDates = dateTimePicker1.Value.ToString();
totalNights = Int32.TryParse(str, out totalNights);
if (rdbEdinburg.Checked == true)
{
int totatcost = (totalNights * 17);
//You can connect here database to save data
MessageBox.Show("A Reservation has been made for " + nameOfCustomer + "The cost is :" + totatcost + "$" + "Arrival Date" + arrivalDates + "for a " + totalNights + "Night(s)");
}
else if (rdbFlorence.Checked == true)
{
int totatcost = (totalNights * 23);
//You can connect here database to save data
MessageBox.Show("A Reservation has been made for " + nameOfCustomer + "The cost is :" + totatcost + "$" + "Arrival Date" + arrivalDates + "for a " + totalNights + "Night(s)");
}
else
{
int totatcost = (totalNights * 19);
//You can connect here database to save data
MessageBox.Show("A Reservation has been made for " + nameOfCustomer + "The cost is :" + totatcost + "$" + "Arrival Date" + arrivalDates + "for a " + totalNights + "Night(s)");
}
}
catch
{
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.