Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2003
    Posts
    104

    Next without for? arrrrgh VBA!

    I am really getting fed up with VBA. I'm a c/c++ guy myself.
    Ok, quick one

    I get a "Next Without For" runtime error for this code. Can anyone help me find out what's wrong?

    Code:
      For x = 1 To 10
        
            val = Me("cmbobxGroup" & CStr(x)).Value
            If (val <> "") Then
                DropDowns(x) = CInt(val)
            Else
                DropDowns(x) = -1 '-1 indicates a null or empty value
            
        Next
    Note that I also did try Next x and that did the same thing.

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    You have an error else where in the program ... Check your other for ... next loops.

    Be aware: VB/VBA can propagate errors VERY FAR away from the point of origin ... It is frustrating.

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,739
    you have a missing endif

    izy
    currently using SS 2008R2

  4. #4
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    It's not often that I miss the missing endif ... I must be going blind ...

  5. #5
    Join Date
    Nov 2003
    Posts
    104
    Oh that darned End If.
    LOOOL.

    thanx for the help guys. I am used to C/C++/java not forcing u to have an "end if"
    LOL

  6. #6
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,739
    Code:
    {
                                           {yeah
    }}}}}} i guess this
                                                               sort of stuff}
    {must be}
                     }
                   }
         much}
     easier}
        to}
                                                             read}
    izy
    currently using SS 2008R2

  7. #7
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969

    Re: Next without for? arrrrgh VBA!

    Originally posted by shassouneh
    I am really getting fed up with VBA. I'm a c/c++ guy myself.
    Ok, quick one

    I get a "Next Without For" runtime error for this code. Can anyone help me find out what's wrong?

    Code:
      For x = 1 To 10
        
            val = Me("cmbobxGroup" & CStr(x)).Value
            If (val <> "") Then
                DropDowns(x) = CInt(val)
            Else
                DropDowns(x) = -1 '-1 indicates a null or empty value
            
        Next
    Note that I also did try Next x and that did the same thing.
    The Syntax of If in VB is like that
    If Condition then
    &nbsp;&nbsp; do smoething
    else
    &nbsp;&nbsp; another thing
    endif

    And you forgot the Endif

  8. #8
    Join Date
    Nov 2003
    Posts
    104
    LOL izy. I just got used to c/c++ syntax that VB syntax just bugs me.

    Code:
    ReturnType FunctionName(parameterList)
    {
    
          This->Seems[To.Be] = Much->EasierToRead;
           (than)VB.code
    }//end of function
    LOL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •