[RESOLVED] Noob here and I need some simple help
OK im new to this sight and could use some help. I am Makeing a simple program that will work but if you donot put ant thing in the spacesit messes up. its pretty much a a program for easy use of the distance formula.
heres the code i have all i need to program in is some way if the box is left blank then it equals 0
Private Sub cmdAdd_Click()
X1 = txtX1.Text
Y1 = txtY1.Text
X2 = txtX2.Text
Y2 = txtY2.Text
B = (X1 - X2) ^ 2 + (Y1 - Y2) ^ 2
B = Sqr(B)
picAnswer.Print B
End Sub
if you guys can help I would really apprieate it
Re: Noob here and I need some simple help
Welcome to VBF! :wave:
You can try something like this...
VB Code:
If Len(txtX1.Text) = 0 Then
X1 = 0
Else
X1 = txtX1.Text
End If
Re: Noob here and I need some simple help
that dident work my main problem is leaving the Text boxes blank and not having numbers in them If there was just a way to have a zero permantly put in front of the text box and only make it so you can type numbers. I need to get this because my teacher trys to crash the programs. Thanks
Re: Noob here and I need some simple help
You may try the validate event of your textboxes...
VB Code:
Private Sub txtX1_Validate(Cancel As Boolean)
If Len(txtX1) = 0 Then
txtX1.Text = "0"
Else
If Not IsNumeric(txtX1) Then
txtX1.Text = "0"
End If
End If
End Sub
Re: Noob here and I need some simple help
cool cool that helped me, :wave: thanks man