Ok Here is what I have so far. I am trying to do the checkbox so that way only one is check at a time. But for some reason they both will check. And another thing I have the labels on there but in the radiobuttons no matter which one you check and submit it only stats the bottom one. Can someone help me and tell me what I am doing wrong...
Public Class Form1
Dim Message As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, MaskedTextBox1.TextChanged
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
If TextBox1.Text <> "" Then
ErrorProvider1.Clear()
Label1.Text = TextBox1.Text
Else
ErrorProvider1.SetError(TextBox1, "Please enter text")
End If
End Sub
Private Sub MonthCalendar1_DateChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MonthCalendar1.DateChanged
Me.Text = Me.MonthCalendar1.SelectionRange.Start.ToShortDateString
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label2.Text = MaskedTextBox1.Text
Label3.Text = RadioButton1.Text
Label3.Text = RadioButton2.Text
Label3.Text = RadioButton3.Text
Label4.Text = CheckBox1.Text
Label5.Text = CheckBox2.Text
Label6.Text = MonthCalendar1.Text
Dim message As String
message = ""
If CheckBox1.Checked Then
message += "first one clicked"
End If
If CheckBox2.Checked Then
message += " second one clicked"
End If
MessageBox.Show(message)
End Sub
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged, RadioButton2.CheckedChanged, RadioButton1.CheckedChanged
Dim radMessage As RadioButton = CType(sender, RadioButton)
If radMessage.Checked Then
Message = radMessage.Text
End If
End Sub
End Class
Ok and this is suppose to be what my commands are suppose to be doing..
Create a new window Project .change the title of the form to Lab3.drag the following controls to your form,textbox,masked textbox (set to phone number),3 radiobuttons in a groupbox(container control),2 checkboxes, Month calendar,all on the left of the form,add a label for each control on the right, add an errorprovider for the textbox and insure it has data entered, add tooltips to every control, add a button
Task
When the user mouses over any control on the left they get a tooltip, change the text on the button to "Submit", when the user clocks the button, the info from the controls on the left appears in the label on the right,if no data is entered in the textbox use the errorprovider control to prompt the user for data, only use 1 label for all three radiobuttons, Only display each check box data if the check boxes checked, make sure to add code to erase the appropriate label if the user UNCHECKS a check box, set the tab order of the controls so you can tab though them in order down the left side, look on the internet to find out how to rettrieve the selected date from the calendar control when the user clicks the button.
I am not expecting anyone to do this for me. I am trying to do the code but i know i mest up some where. I am still a newbie at this so sorry.
I don't expect this answer to solve all of your problems but hopefully it should prove a starting point.
Firstly, why do you want only one checkbox to be selected at any moment? I can't see that as a requirement in your task? By default checkboxes do not exhibit that behaviour (that is what radio buttons are for), but they can be made to. To do this you would need to look at the selected_change event of the checkbox and when one is selected, deselect all the others. However before you do that, make sure it is what you are after before progressing.
With the radio buttons issue, I am assuming you want to set the text of the selected radio button into a label? Well currently you are assigning the selected text into a field, Message, but you are not using this anywhere else. When you set up your labels you have the following:
Label3.Text = RadioButton1.Text
Label3.Text = RadioButton2.Text
Label3.Text = RadioButton3.Text
Whereas I am guessing you need something along the lines of
Label3.Text = Message
At the moment you are setting the same Label text three times and only the third radio button text will be displayed.
On another note I would possibly think about using different variable names that Message as it could result in some confusion later on.
Hope that gets you somewhere
Related
I'm using a VB.NET form that contains two panels; I want the user to be able to enter a string value in a textbox on panel 1, and have it appear in a label in panel 2.
Basic Example:
Private Sub TextBox1_KeyUp(sender As Object, e As KeyEventArgs) Handles TextBox1.KeyUp
Label1.Text = TextBox1.Text
End Sub
Don't worry about whether or not they're in different panels.
How do I make a combo box password or button password? I got this code and it does not work.
Public Class Form1
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If ComboBox1.Text = "5" Then
If ComboBox2.Text = "3" Then
If ComboBox3.Text = "2" Then
If ComboBox4.Text = "6" Then
Button1.Enabled = True
End If
End If
End If
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox("Dony", MsgBoxStyle.Information, "Dony")
Application.Exit()
End Sub
When combo box's item is 5, then it will allow the other combo box to be 3 and if the second combo box is 3 it will allow the third combo box to be 6 and if that happens it will allow the fourth combo box to be 2 and then if that happens the button is enabled.
Anyone help?
Your function run only when you change the selected index in your ComboBox1. Button1 will only be enabled if you choose your value for Combobox1 after you have selected all the good values for the others ComboBoxes. You should put this code in another function that you can call every time you select a value in one of your four ComboBoxes.
First of all: your code will only be executed after the first Combobox get changed. So it will only check the second, the third and the fourth position AFTER the first ComboBox get changed.
The solution for your problem is to add the other ComboBoxes as a Handler for your function. Also you listen to the wrong event. SelectedIndexChanged only get triggered if the user choose another answer from the list. But what if the user typed in the code? The correct event is the TextChanged event which also trigger the function if the user type in the code.
Private Sub CheckCode(sender As Object, e As EventArgs) Handles ComboBox1.TextChanged, ComboBox2.TextChanged, ComboBox3.TextChanged, ComboBox4.TextChanged
If ComboBox1.Text = "5" Then
If ComboBox2.Text = "3" Then
If ComboBox3.Text = "2" Then
If ComboBox4.Text = "6" Then
Button1.Enabled = True
End If
End If
End If
End If
End Sub
Personally, I would not handle it that way, but it definitely solves your problem.
i solved the problem.
The code is
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If NumericUpDown1.Value = 5 And NumericUpDown2.Value = 3 And NumericUpDown3.Value = 2 And NumericUpDown4.Value = 6 Then
Me.Close() 'Command here.
End If
End Sub
If Anyone wants to know.
You must have a code in other comboboxes, not only on the first one.
your code must be like this:
if combobox1.text = 5 and combobox2.text = 3 and combobox3.text = 2 and combobox4.text = 6 then
button1.enabled = true
else
button1.enabled = false
endif
all of the comboboxes has the same code, i think. just try it :)
Greetings and salutations. I really need help for school.
This is what I'm dealing with:
Cannot make selection until one option is picked.
The "You have selected a hostel location" text shouldn't show up until "Select Location" is pressed.
My assignment is a hostel selection, allowing the user to select one or the other. Once the selection is made via btnselect, lblselected is supposed to show up, then the window is supposed to close.
Please help me. I have no idea what I'm doing. I'm a web designer trying to expand my knowledge.
Option Explicit On
Public Class frmhostelselection
Private Sub btnlondon_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlondon.Click
End Sub
Private Sub btndublin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndublin.Click
End Sub
Private Sub btnselect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnselect.Click
End Sub
Private Sub btnexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnexit.Click
End Sub
Private Sub lblselected_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblselected.Click
End Sub
Private Sub lblmsg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblmsg.Click
End Sub
End Class
Ok, i get you a logic
First on you loadsub
you must add
londonlistbox.enabled = false
dublinlistbox.enabled = false
then, add to you london button
dublinlistbox.enabled = false
london.enabled = false
and add the opposite to the dublin button
then, select location
select case londonlistbox and dublinlistbox
case londonlistbox.enabled = true
label1.text = londonlistbox.selecteditems
case dublinlistbox.enabled = true
label1.text = dublinlistbox.selecteditems
that's all
You want to hide the label. In visual studio, you want to select the label, and set its visible value to false. Or you can set it to be invisible for the formload event.
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
lblselected.visible = false
end sub
You then need it to show for the button click event.
lblselected.visible = true
From your picture i am unsure what the buttons are to do. You seem to have 2 actual locations to choose (as buttons) and another button which seems to act as a select button.
You also have requested a select case command in your question.
So perhaps you want t select case to load when you click the select location button, and that a value will be set if you click either of the other buttons?
As above said, you have made no attempt to try this yourself, so i won't write the code, but it sounds like you want this...
The 2nd label should be invisible until the select button is clicked.
You want to string or something that will identify what has been pressed. This string should be a global variable that is declared beneath the public path.
When either londen button or... other button is pressed, the global string should change to either London or...Dublin.
When you press the select button, it should load a select case method which will check for either london or dublin.
Select case globalstring
case "London"
' make label visible, maybe change lblselected text to reflect that London was pressed.
case "Dublin"
' Make label visible, maybe change lblselected text to reflect that Dublin was pressed.
case default
' Produce an error message saying that nothing was pressed.
end Select
I'm guessing you also want images to show in those pictureboxs. Use initial image to get that one.
And the exit button will just be me.close()
I have a really quick and simple question, I’m learning programming in C# and VB and I need to create a GUI application in Windows Form with Visual Studio. This GUI will prompt the user to enter in an integer. I believe I have this part alright but then I need to have the user click a button that will convert the user's entry to an integer and display a message indicating whether the user was successful. I think I even have the conversion done correctly but I am having a problem displaying that message if the user was successful. Basically I need to know how to function the click method in VB that will allow this message to appear. Any help with this would be greatly appreciated. The following code is what I have already written for this project:
Public Class Form1
Private Sub EvaluateInput()
Dim InputValue As String
InputValue = ValueTextBox.Text
If IsNumeric(InputValue) Then
MessageBox.Show(InputValue & " is a number.")
Else
MessageBox.Show(InputValue & " is not a number.")
End If
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click 'Continue Button
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'Exit Button
Dim button As DialogResult
button = MessageBox.Show _
("Are you sure you want to exit this application?", _
"Message", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)
If button = Windows.Forms.DialogResult.Yes Then
Me.Close()
Else
'Do Nothing
End If
End Sub
End Class
If I understand your question correctly, then you would need a simply change:
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) _
Handles Button2.Click 'Continue Button
EvaluateInput()
End Sub
When you press Button2, it will call the EvaluateInput sub and display a message accordingly.
Using VB.Net
2 textbox in the Form (textbox1.text, textbox2.text)
Once user entered the value in the textbox1 means automatically textbox1 value should appear in the textbox2 without clicking the buttons.
In which event i have to write a code instead of button clicking event....
Need vb.net code Help
Try this..
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
TextBox2.Text = TextBox1.Text
End Sub
Every time you type a value in textbox1 it will appear in textbox2