|
-
Jun 12th, 2008, 04:13 AM
#1
Thread Starter
Fanatic Member
VB.Net 2008 - 3 Check Boxes, 3 Text Boxes - Adding if Check box is checked.
Hey guys, I think I am posting this in the right place.
I am rather happy and quite impressed with this. Be it quite simple, I am still impressed .
But I am sure there is room for improvment.
vb.net Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Num As Integer ' Declars Num as a Number
If CheckBox1.Checked = True Then ' Checks if the checkbox is checked
If TextBox1.TextLength > 0 Then ' Checks if Textbox is checked
If IsNumeric(TextBox1.Text) = True Then ' Checks if text is a number
Num = Num + TextBox1.Text ' Number + what ever is inside textbox1
Else
TextBox1.Text = 0
End If
End If
End If
If CheckBox2.Checked = True Then ' Checks if the checkbox is checked
If TextBox2.TextLength > 0 Then ' Checks if Textbox is checked
If IsNumeric(TextBox2.Text) = True Then ' Checks if text is a number
Num = Num + TextBox2.Text ' Number + what ever is inside textbox2
Else
TextBox2.Text = 0
End If
End If
End If
If CheckBox3.Checked = True Then ' Checks if the checkbox is checked
If TextBox3.TextLength > 0 Then ' Checks if Textbox is checked
If IsNumeric(TextBox3.Text) = True Then ' Checks if text is a number
Num = Num + TextBox3.Text ' Number + what ever is inside textbox3
Else
TextBox3.Text = 0
End If
End If
End If
RichTextBox1.Text = Num ' Displays total of Number
Num = 0 ' Resets number for next time button is pressed
End Sub
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
|