|
-
May 19th, 2013, 12:02 AM
#1
Thread Starter
Member
How come this doesn't work...?
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If RadioButton1.Checked AndAlso RadioButton13.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add(TextBox1.Text)
ElseIf RadioButton2.Checked AndAlso RadioButton13.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("cyan:" & TextBox1.Text)
ElseIf RadioButton3.Checked AndAlso RadioButton13.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("green:" & TextBox1.Text)
ElseIf RadioButton4.Checked AndAlso RadioButton13.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("purple:" & TextBox1.Text)
ElseIf RadioButton5.Checked AndAlso RadioButton13.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("red:" & TextBox1.Text)
ElseIf RadioButton6.Checked AndAlso RadioButton13.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("white:" & TextBox1.Text)
ElseIf RadioButton7.Checked AndAlso RadioButton13.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("flash1:" & TextBox1.Text)
ElseIf RadioButton8.Checked AndAlso RadioButton13.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("flash2:" & TextBox1.Text)
ElseIf RadioButton9.Checked AndAlso RadioButton13.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("flash3:" & TextBox1.Text)
ElseIf RadioButton10.Checked AndAlso RadioButton13.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("glow1:" & TextBox1.Text)
ElseIf RadioButton11.Checked AndAlso RadioButton13.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("glow2:" & TextBox1.Text)
ElseIf RadioButton12.Checked AndAlso RadioButton13.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("glow3:" & TextBox1.Text)
ElseIf RadioButton1.Checked AndAlso RadioButton14.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("scroll:" & TextBox1.Text)
ElseIf RadioButton1.Checked AndAlso RadioButton15.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("shake:" & TextBox1.Text)
ElseIf RadioButton1.Checked AndAlso RadioButton16.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("slide:" & TextBox1.Text)
ElseIf RadioButton1.Checked AndAlso RadioButton17.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("wave:" & TextBox1.Text)
ElseIf RadioButton1.Checked AndAlso RadioButton18.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("wave2:" & TextBox1.Text)
ElseIf RadioButton2.Checked AndAlso RadioButton14.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("cyan:" & "scroll:" & TextBox1.Text)
ElseIf RadioButton2.Checked AndAlso RadioButton15.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("cyan:" & "shake:" & TextBox1.Text)
ElseIf RadioButton2.Checked AndAlso RadioButton16.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("cyan:" & "slide:" & TextBox1.Text)
ElseIf RadioButton2.Checked AndAlso RadioButton17.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("cyan:" & "wave:" & TextBox1.Text)
ElseIf RadioButton2.Checked AndAlso RadioButton18.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("cyan:" & "wave2:" & TextBox1.Text)
ElseIf RadioButton3.Checked AndAlso RadioButton14.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("green:" & "scroll:" & TextBox1.Text)
ElseIf RadioButton3.Checked AndAlso RadioButton15.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("green:" & "shake:" & TextBox1.Text)
ElseIf RadioButton3.Checked AndAlso RadioButton16.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("green:" & "slide:" & TextBox1.Text)
ElseIf RadioButton3.Checked AndAlso RadioButton17.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("green:" & "wave:" & TextBox1.Text)
ElseIf RadioButton3.Checked AndAlso RadioButton18.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("green:" & "wave2:" & TextBox1.Text)
ElseIf RadioButton4.Checked AndAlso RadioButton14.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("purple:" & "scroll:" & TextBox1.Text)
ElseIf RadioButton4.Checked AndAlso RadioButton15.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("purple:" & "shake:" & TextBox1.Text)
ElseIf RadioButton4.Checked AndAlso RadioButton16.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("purple:" & "slide:" & TextBox1.Text)
ElseIf RadioButton4.Checked AndAlso RadioButton17.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("purple:" & "wave:" & TextBox1.Text)
ElseIf RadioButton4.Checked AndAlso RadioButton18.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("purple:" & "wave2:" & TextBox1.Text)
ElseIf RadioButton5.Checked AndAlso RadioButton14.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("red:" & "scroll:" & TextBox1.Text)
ElseIf RadioButton5.Checked AndAlso RadioButton15.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("red:" & "shake:" & TextBox1.Text)
ElseIf RadioButton5.Checked AndAlso RadioButton16.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("red:" & "slide:" & TextBox1.Text)
ElseIf RadioButton5.Checked AndAlso RadioButton17.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("red:" & "wave:" & TextBox1.Text)
ElseIf RadioButton5.Checked AndAlso RadioButton18.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("red:" & "wave2:" & TextBox1.Text)
ElseIf RadioButton6.Checked AndAlso RadioButton14.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("white:" & "scroll:" & TextBox1.Text)
ElseIf RadioButton6.Checked AndAlso RadioButton15.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("white:" & "shake:" & TextBox1.Text)
ElseIf RadioButton6.Checked AndAlso RadioButton16.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("white:" & "slide:" & TextBox1.Text)
ElseIf RadioButton6.Checked AndAlso RadioButton17.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("white:" & "wave:" & TextBox1.Text)
ElseIf RadioButton6.Checked AndAlso RadioButton18.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("white:" & "wave2:" & TextBox1.Text)
ElseIf RadioButton7.Checked AndAlso RadioButton14.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("flash1:" & "scroll:" & TextBox1.Text)
ElseIf RadioButton7.Checked AndAlso RadioButton15.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("flash1:" & "shake:" & TextBox1.Text)
ElseIf RadioButton7.Checked AndAlso RadioButton16.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("flash1:" & "slide:" & TextBox1.Text)
ElseIf RadioButton7.Checked AndAlso RadioButton17.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("flash1:" & "wave:" & TextBox1.Text)
ElseIf RadioButton7.Checked AndAlso RadioButton18.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("flash1:" & "wave2:" & TextBox1.Text)
ElseIf RadioButton8.Checked AndAlso RadioButton14.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("flash2:" & "scroll:" & TextBox1.Text)
ElseIf RadioButton8.Checked AndAlso RadioButton15.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("flash2:" & "shake:" & TextBox1.Text)
ElseIf RadioButton8.Checked AndAlso RadioButton16.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("flash2:" & "slide:" & TextBox1.Text)
ElseIf RadioButton8.Checked AndAlso RadioButton17.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("flash2:" & "wave:" & TextBox1.Text)
ElseIf RadioButton8.Checked AndAlso RadioButton18.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("flash2:" & "wave2:" & TextBox1.Text)
ElseIf RadioButton9.Checked AndAlso RadioButton14.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("flash3:" & "scroll:" & TextBox1.Text)
ElseIf RadioButton9.Checked AndAlso RadioButton15.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("flash3:" & "shake:" & TextBox1.Text)
ElseIf RadioButton9.Checked AndAlso RadioButton16.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("flash3:" & "slide:" & TextBox1.Text)
ElseIf RadioButton9.Checked AndAlso RadioButton17.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("flash3:" & "wave:" & TextBox1.Text)
ElseIf RadioButton9.Checked AndAlso RadioButton18.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("flash3:" & "wave2:" & TextBox1.Text)
ElseIf RadioButton10.Checked AndAlso RadioButton14.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("glow1:" & "scroll:" & TextBox1.Text)
ElseIf RadioButton10.Checked AndAlso RadioButton15.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("glow1:" & "shake:" & TextBox1.Text)
ElseIf RadioButton10.Checked AndAlso RadioButton16.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("glow1:" & "slide:" & TextBox1.Text)
ElseIf RadioButton10.Checked AndAlso RadioButton17.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("glow1:" & "wave:" & TextBox1.Text)
ElseIf RadioButton10.Checked AndAlso RadioButton18.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("glow1:" & "wave2:" & TextBox1.Text)
ElseIf RadioButton11.Checked AndAlso RadioButton14.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("glow2:" & "scroll:" & TextBox1.Text)
ElseIf RadioButton11.Checked AndAlso RadioButton15.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("glow2:" & "shake:" & TextBox1.Text)
ElseIf RadioButton11.Checked AndAlso RadioButton16.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("glow2:" & "slide:" & TextBox1.Text)
ElseIf RadioButton11.Checked AndAlso RadioButton17.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("glow2:" & "wave:" & TextBox1.Text)
ElseIf RadioButton11.Checked AndAlso RadioButton18.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("glow2:" & "wave2:" & TextBox1.Text)
ElseIf RadioButton12.Checked AndAlso RadioButton14.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("glow3:" & "scroll:" & TextBox1.Text)
ElseIf RadioButton12.Checked AndAlso RadioButton15.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("glow3:" & "shake:" & TextBox1.Text)
ElseIf RadioButton12.Checked AndAlso RadioButton16.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("glow3:" & "slide:" & TextBox1.Text)
ElseIf RadioButton12.Checked AndAlso RadioButton17.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("glow3:" & "wave:" & TextBox1.Text)
ElseIf RadioButton12.Checked AndAlso RadioButton18.Checked AndAlso TextBox1.Text <> Nothing Then
ListBox1.Items.Add("glow3:" & "wave2:" & TextBox1.Text)
End If
If TextBox1.Text <> Nothing Then
RadioButton1.Checked = True
RadioButton13.Checked = True
TextBox1.Text = ""
TextBox1.Select()
Else
MessageBox.Show("The message box contains no characters.")
End If
End Sub
Code:
Private Sub TextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = Keys.Enter Then
e.SuppressKeyPress = True
Call Button1_Click()
End If
End Sub
-
May 19th, 2013, 01:35 AM
#2
Fanatic Member
Re: How come this doesn't work...?
please elaborate before someone curses you .
is it loading the form, are there results showing but incorrect, whats happening?
Yes!!!
Working from home is so much better than working in an office...
Nothing can beat the combined stress of getting your work done on time whilst
1. one toddler keeps pressing your AVR's power button
2. one baby keeps crying for milk
3. one child keeps running in and out of the house screaming and shouting
4. one wife keeps nagging you to stop playing on the pc and do some real work.. house chores
5. working at 1 O'clock in the morning because nobody is awake at that time
6. being grossly underpaid for all your hard work

-
May 19th, 2013, 01:43 AM
#3
Fanatic Member
Re: How come this doesn't work...?
Hi,
try putting all the code on the click event into a sub
then call the sub from the click event and the keydown event, its tidy that way when your events are not jammed with code
and remember the rules of subs ()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
there are 2 arguments required here, sender and e.
so you will have to pass the textbox info into the click sub event, looks messy, just make a sub
Yes!!!
Working from home is so much better than working in an office...
Nothing can beat the combined stress of getting your work done on time whilst
1. one toddler keeps pressing your AVR's power button
2. one baby keeps crying for milk
3. one child keeps running in and out of the house screaming and shouting
4. one wife keeps nagging you to stop playing on the pc and do some real work.. house chores
5. working at 1 O'clock in the morning because nobody is awake at that time
6. being grossly underpaid for all your hard work

-
May 19th, 2013, 12:39 PM
#4
Re: How come this doesn't work...?
Also think about the logic of your conditionals. All of them require that TextBox1.Text <> Nothing (that should actually be <> "", by the way) so you can make that the first step (not only more logical but more efficient as an empty textbox means that no processing of the other conditionals is needed). Then you can take advantage of a neat little trick with Select Case, for example ...
vb.net Code:
If TextBox1.Text <> "" Then
Select Case True ' which values = True, a twist on the more usual 'what value is held by a variable'
Case RadioButton1.Checked AndAlso RadioButton4.Checked
Me.Text = "1 and 4"
Case RadioButton1.Checked AndAlso RadioButton5.Checked
Me.Text = "1 and 5"
'etc
End Select
End If
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|