Newbie Question

Clintimania

Registered User.
Local time
Today, 12:20
Joined
Nov 21, 2006
Messages
60
Ok so this has to be easy.. but for some reason I am struggling with this. I am writing some long code and I want to go to the next line because its going off the page and its hard to keep track of. So when I move an "Or" to the next line instead of continuing the line, it gives me errors. How do I make code work on multiple lines instead of one huge long line.

Example.

Turn below:
If this or this or this or this or this or this or this or this or this else

Into:
If this or this
or this or this
or this or this Else

Dont laugh :(
 
You would need to use the line continuation character _

Though if you have that many "or" conditions I would consider writing that validation as its own function.
 
you should also use the select statement

Code:
Private Sub SelectStatementExample(byval sVal as String)

    Select Case sVal

       Case "A"
            'do something
       Case "B"
            'do something
       Case "C"
            'do something
       Case "D"
            'do something
       Case Else
            'I am doing something wrong.
    End Select

End Sub
 
Apart from using the underscore continuation character you can also do this

Dim sSql as String

Code:
       sSql = "Some Code"
sSql = sSql & "Some More Code"
sSql = sSql & "Some More Code"
sSql = sSql & "etc etc etc"


David
 

Users who are viewing this thread

Back
Top Bottom