Soldato
- Joined
- 30 Dec 2004
- Posts
- 4,681
- Location
- Bromley, Kent
As title really.
That's my code at the moment which works for my all mighty number cruncher. I'm not looking to optimize or make it more efficient at the moment.
When the loop scans the values in box 1 and two, if the boxes are blank then it stops the loop, but what i want to happen is exactly this, but also have a message box pop up to say something like "first box empty" on the top box and "second box empty" on the second box, I can't seem to work out how to make the pop up appear in the same snippet of code where the value is checked due to it executing the Exit Sub command.
Hope that makes sense, if not just say.
Thanks all
- Pea0n
Code:
Public Class BetweenNumberAdd
Dim number As Integer
Dim firstnumber As Integer
Dim startnumber As Integer
Dim endnumber As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If startnumber = 0 Then
Exit Sub
End If
If endnumber = 0 Then
Exit Sub
End If
For firstnumber = startnumber To endnumber
number = number + firstnumber
Next firstnumber
MessageBox.Show(number)
End Sub
Private Sub startnumberbox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles startnumberbox.TextChanged
startnumber = Val(startnumberbox.Text)
End Sub
Private Sub endnumberbox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles endnumberbox.TextChanged
endnumber = Val(endnumberbox.Text)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
startnumberbox.Text = " "
endnumberbox.Text = " "
number = "0"
firstnumber = "0"
startnumber = "0"
endnumber = "0"
End Sub
End Class
That's my code at the moment which works for my all mighty number cruncher. I'm not looking to optimize or make it more efficient at the moment.
When the loop scans the values in box 1 and two, if the boxes are blank then it stops the loop, but what i want to happen is exactly this, but also have a message box pop up to say something like "first box empty" on the top box and "second box empty" on the second box, I can't seem to work out how to make the pop up appear in the same snippet of code where the value is checked due to it executing the Exit Sub command.
Hope that makes sense, if not just say.
Thanks all
- Pea0n