Tough firstly because I've no idea where to post this. I'm doing chemistry but as a drive to the "integrate computers into chemistry" ethos we've had to write a program in visual basic. I've no idea with this as all I've ever done is C.
My problem is when I leave one of my data input boxes empty the program dies.
I've done all the program and it works I just need to know a line that will pick up any errors and jump the :valueerror bit at the end. Once there it will print out the error message and won't die. Can anyone help.
Psedocode:
If error encounterd then goto valueerror.
Thanks anyone who can help
Code:Dim constant As Single Dim alpha1 As Single Dim alpha2 As Single Dim alpha3 As Single Dim beff As Single Dim v1 As Single Dim v2 As Single Dim v3 As Single Dim counter As Integer Dim testfile As String Dim titlev1 As String Dim titlev2 As String Dim titlev3 As String Dim titlebeff As String titlev1 = "v1" titlev2 = "v2" titlev3 = "v3" titlebeff = "B(eff)" constant = conbox.Text alpha1 = alpha1box.Text alpha2 = alpha2box.Text alpha3 = alpha3box.Text testfile = "p:\rotat.txt" Open testfile For Output As #1 Write #1, titlev1, titlev2, titlev3, titlebeff For v1 = 0 To 2 For v2 = 0 To 2 For v3 = 0 To 2 beff = (constant - (alpha1 * (v1 + (1 / 2))) - (alpha2 * (v2 + (1 / 2))) - (alpha3 * (v3 + (2 / 2)))) Write #1, v1, v2, v3, beff Next v3 Next v2 Next v1 Close #1 valueerror: If Err.Number = 13 Then Msg = "You have forgotten to fill in one of the boxes!" MsgBox Msg End If Exit Sub



LinkBack URL
About LinkBacks


