Thread: Bit a tough one

  1. #1
    Registered User
    Join Date
    Sep 2002

    Bit a tough one

    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.

    If error encounterd then goto valueerror.

    Thanks anyone who can help

    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
    If Err.Number = 13 Then
    Msg = "You have forgotten to fill in one of the boxes!"
    MsgBox Msg
    End If
    Exit Sub

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    You might want to try asking at
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    Registered User mepaco's Avatar
    Join Date
    Aug 2002
    Here is a simple routine that closes some databases with error handling in it.
    Private Sub Form_Unload(Cancel As Integer)
    On Error GoTo Error_Handler
        If Err.Number = 91 Then Resume Next
    End Sub

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Doesn't your debugger help you?

    Do you have something like:
    On Error Goto valueerror
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 16 bit compilar or 32 bit compilar
    By rajkumarmadhani in forum C Programming
    Replies: 16
    Last Post: 12-04-2007, 09:48 AM
  2. Replies: 3
    Last Post: 11-10-2005, 10:53 AM
  3. porting application from 32 bit to 64 bit error
    By gandalf_bar in forum Linux Programming
    Replies: 1
    Last Post: 09-14-2005, 09:20 AM
  4. Bit processing in C
    By eliomancini in forum C Programming
    Replies: 8
    Last Post: 06-07-2005, 10:54 AM
  5. Bit Manipulation Questions
    By CPPNewbie in forum C++ Programming
    Replies: 7
    Last Post: 08-12-2003, 02:17 PM