I have about 5 hidden textbox, and 1 button that when I click It it shows the hiddentext 1 by 1, but what I want to do is when I click the button once only 1 textbox appears and then a message box will appear saying "Do you want to Continue" YES or NO? if I press Yes, then the 2nd textbox will appear, but when I press No the messagebox should be closed.
I have this Code on the Button:
Private Sub revealtxtbox_Click(ByVal senders As System.Object, ByVal e As System.EventArgs) Handles revealtxtbox.Click
txtbox1.visible = True
If MsgBox("Do you Want to Continue", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Sample System") = MsgBoxResult.Yes then
txtbox2.visible = true
Elseif MsgBoxResult.Yes then
txtbox3.visible = true
Elseif MsgBoxResult.Yes then
txtbox4.visible = true
Elseif MsgBoxResult.Yes then
txtbox5.visible = true
End if
the code above somewhat works but when I press NO, the txtbox3 shows and the msgbox closed, it should not show txtbox3, it should only close the msgbox.
Try something more like this instead:
Private Sub revealtxtbox_Click(ByVal senders As System.Object, ByVal e As System.EventArgs) Handles revealtxtbox.Click
txtbox1.visible = True
If MsgBox("Do you Want to Continue", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Sample System") <> MsgBoxResult.Yes then
Exit Sub
End If
txtbox2.visible = true
If MsgBox("Do you Want to Continue", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Sample System") <> MsgBoxResult.Yes then
Exit Sub
End If
txtbox3.visible = true
If MsgBox("Do you Want to Continue", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Sample System") <> MsgBoxResult.Yes then
Exit Sub
End If
txtbox4.visible = true
If MsgBox("Do you Want to Continue", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Sample System") <> MsgBoxResult.Yes then
Exit Sub
End If
txtbox5.visible = true
End if
Related
This code is deleting the selected item in listview except for some reason it's showing the response 2 times and deleting the data twice. It should only appear once to confirm if i want to delete the item that i selected.
Dim response As Integer
For Each i As ListViewItem In ListView.SelectedItems
response = MsgBox("Are you sure you want to delete " + TextBox.Text, vbYesNo, "Confirm Delete")
If response = vbYes Then
ListView.Items.Remove(i)
End If
Next
You need to exit the for loop
Dim response As Integer
For Each i As ListViewItem In ListView.SelectedItems
response = MsgBox("Are you sure you want to delete " + TextBox.Text, vbYesNo, "Confirm Delete")
If response = vbYes Then
ListView.Items.Remove(i)
goto Here
End If
Next
Here:
by the way, this is vb.net, edit your post with vb.net tag please.
Step1 Changing ListView1 properties following below picture
enter image description here
Step2 Using this code:
Private Sub ListView1_ItemChecked(sender As Object, e As ItemCheckedEventArgs) Handles ListView1.ItemChecked
Dim i As ListViewItem
For Each i In ListView1.SelectedItems
Select Case MsgBox("Are you sure you want to delete selected record?", MsgBoxStyle.YesNo, "Confirm Delete")
Case MsgBoxResult.Yes
ListView1.Items.Remove(i)
Case MsgBoxResult.No
End Select
Next
End Sub
In my project, I use the code below (It is working):
Private Sub ListView1_ItemChecked(sender As Object, e As ItemCheckedEventArgs) Handles ListView1.ItemChecked
Dim i As ListViewItem
For Each i In ListView1.SelectedItems
Select Case MsgBox("คุณต้องการลบรายการขายสินค้าที่ถูกเลือกใช่ไหม", MsgBoxStyle.YesNo, "ยืนยันการลบรายการขายสินค้า")
Case MsgBoxResult.Yes
ListView1.Items.Remove(i)
txt_barcode.Text = ""
txt_barcode.Select()
txt_total.Text = FormatNumber(total_price)
txt_cost.Text = FormatNumber(total_buy)
txt_profit.Text = FormatNumber(total_price) - FormatNumber(total_buy)
txt_Quantity.Text = "1"
lbl_BarcodeID.Text = ""
lbl_Description.Text = ""
lbl_Price.Text = ""
Case MsgBoxResult.No
End Select
Next
End Sub
When the user presses the "Cancel" button in SaveFileDialog I want to rename a textlabel.
Private Sub SaveFileDialog1_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles SaveFileDialog1.FileOk
Label6.Text = "Saved!"
End sub
This is working for the "Save" Button. I don't know how to do it for the "Cancel" button.
Thanks
Instead of using that event, why not compare the result returned from the ShowDialog() method?
If SaveFileDialog1.ShowDialog() = DialogResult.Ok
Label6.Text = "Saved!"
Else
Label6.Text = "Cancelled!"
End If
I prefer the use of cases for something like this
Select Case SaveFileDialog1.ShowDialog()
Case DialogResult.Ok
Label6.Text = "Saved!"
Case DialogResult.Cancel
Label6.Text = "Cancelled!"
End Select
VISUAL BASIC: You know how you can make your own settings in your program setting/properties, well I made a register system for a software. You register by entering a password and username then pressing 'Register' to save the username and password to My.Settings.Username and My.Settings.Password using My.Settings.Save().
The code: My.Settings.Username = TextBox1.Text
My.Settings.Password = TextBox2.Text
My.Settings.Save()
This all works perfectly but how can I prevent the user from changing it again.
This is my code so far:
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim res As MsgBoxResult
If Not My.Settings.Username = String.Empty And
My.Settings.Password = String.Empty Then
MsgBox("You have registered a WCUE account, please use 'CHANGE PASSWORD' in 'Settings' to do so.", MsgBoxStyle.Exclamation, "Not possible.")
ElseIf TextBox1.Text = String.Empty Or
TextBox2.Text = String.Empty Then
MsgBox("Don't press the register button if the text boxes are empty!", MsgBoxStyle.Critical, "Fill all required fields please.")
Else
If TextBox1.Text = My.Settings.Username And
TextBox2.Text = My.Settings.Password Then
MsgBox("If you are trying to log in then press the 'Log-in' text below the register button!", MsgBoxStyle.Exclamation, "You have already registered!")
Else
res = MsgBox("Register a WCUE account?", MsgBoxStyle.YesNo, "Create")
If res = MsgBoxResult.Yes Then
My.Settings.Username = TextBox1.Text
My.Settings.Password = TextBox2.Text
My.Settings.Save()
MsgBox("You can now login to WCUE and set the time limit on this user!", MsgBoxStyle.Information, "YEAH - Register successful!")
ElseIf res = MsgBoxResult.No Then
MsgBox("You should register as quick as possible before someone unauthorized sets a password!!", MsgBoxStyle.Exclamation, "Suit yourself.")
End If
End If
Exit Sub
End If
End Sub
The FIRST if statement is what I am having trouble with, I tried to check if My.Settings.Username and My.Setting.Password contains a value (string) which should be the username and password, if it does not then you can register but if it does contain a value then it tells you that someone has already registered. Nothing happens?
I hope this is clear enough, please help!
I ~think~ this is what you're trying to do...
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
If My.Settings.Username <> String.Empty AndAlso My.Settings.Password <> String.Empty Then
MsgBox("You have registered a WCUE account, please use 'CHANGE PASSWORD' in 'Settings' to do so.", MsgBoxStyle.Exclamation, "Not possible.")
Else
If TextBox1.Text = String.Empty OrElse TextBox2.Text = String.Empty Then
MsgBox("Don't press the register button if the text boxes are empty!", MsgBoxStyle.Critical, "Fill all required fields please.")
Else
Dim res As MsgBoxResult
res = MsgBox("Register a WCUE account?", MsgBoxStyle.YesNo, "Create")
If res = MsgBoxResult.Yes Then
My.Settings.Username = TextBox1.Text
My.Settings.Password = TextBox2.Text
My.Settings.Save()
MsgBox("You can now login to WCUE and set the time limit on this user!", MsgBoxStyle.Information, "YEAH - Register successful!")
ElseIf res = MsgBoxResult.No Then
MsgBox("You should register as quick as possible before someone unauthorized sets a password!!", MsgBoxStyle.Exclamation, "Suit yourself.")
End If
End If
End If
End Sub
Forgive me if this is not possible, here's the scenario.
I have 2 textboxes, I type something on textbox1 and press enter, the text goes to textbox2 and the program presses the enter key on textbox2(user will not press the enter key).
Here's what I have in textbox1_keydown
if e.keycode = keys.enter then
str = textbox1.text
textbox2.focus()
textbox2.text = str
'Make textbox2 press the enter key here, without user pressing it on keyboard
end if
Found the answer
if e.keycode = keys.enter then
str = textbox1.text
textbox2.focus()
textbox2.text = str
'Make textbox2 press the enter key here, without user pressing it on keyboard
SendKeys.Send("{ENTER}")
end if
If e.keycode = Keys.Enter Then
'/* Check whether textbox1 is empty or not */
If textbox1.text <> "" Then
textbox2.text = ""
textbox2.text = textbox1.text
SendKeys.Send("{ENTER}")
Else
'/* if textbox1 is empty then cursor focus on textbox1 only */
textbox1.focus()
End If
End If
OR
If e.keycode = Keys.Enter Then
textbox2.text = ""
textbox2.text = textbox1.text
SendKeys.Send("{ENTER}")
End If
I've made a button1 that if you click on it it starts the timer. In timer_tick I typed Label7.Text = "L O A D I N G". I've made also Exit (Button2). I want to do a code that if Label7.Text = "L O A D I N G" then the msgboxresult.no in button2 will be Button1.Enabled = True . Here is video how I want to do that: http://www.youtube.com/watch?v=4URYhd0xA8I&feature=youtu.be
Here is the code for Button2 (Exit)
Dim msg As String
Dim title As String
Dim style As MsgBoxStyle
Dim response As MsgBoxResult
msg = "Are you sure you want to exit?" ' Define message for exit."
style = MsgBoxStyle.DefaultButton2 Or _
MsgBoxStyle.Question Or MsgBoxStyle.YesNo
title = "Exit"
' Display message.
response = MsgBox(msg, style, title)
If response = MsgBoxResult.No Then
If Label7.Text = "L O A D I N G" Then
Button1.Enabled = True
Button5.Enabled = False
TextBox1.Enabled = True
End If
End If
If response = MsgBoxResult.Yes Then
Me.Close()
End If
I could just simply do:
If response = MsgBoxResult.No Then
Button1.Enabled = True
but it is important that label7 is also mentioned, because label7 shows up when timer1 starts. Please help I don't know what is happening.