Message 1 of 11
VBA question reguarding syntax
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm very new to VBA and I'm still struggling with simple syntax issues. That said I admit that I'm stupid about this and I'm asking for help please?
I'm writing a VBA app to open a simple dialogue with Checkboxes and Option buttons which settings determine the electrical and plumbing schematic block is to be inserted into a drawing. Then, the correct AUTOLISP command is compiled and output to the Command line while exiting the dialogue.
This all works fine until I need to check if two or more statements are true at the same time. I tried to use a if, and, then, elseif, else statement but is doesn't seem to recognize the statement at all? here is an example:
Function GetEQ()
If SpaOnly And Raised = True Then
EQ$ = "RSWV"
ElseIf PoolSpa And PCC = True Then EQ$ = "PCS"
ElseIf PoolOnly And PCC = True Then EQ$ = "PC2"
ElseIf SpaOnly And Vac = True Then EQ$ = "SWV"
ElseIf PoolOnly = True Then EQ$ = "NP"
ElseIf SpaOnly = True Then EQ$ = "SWV"
ElseIf PoolSpa = True Then EQ$ = "PAS"
Else
PoolOnly = False: SpaOnly = False: Raised = False: Vac = False: PVal = False: NoBooster = False: PCC = False: Att = False: Sepr = False: SpaB = False: TwoSkims = False: Frog = False: Salt = False: DiChlor = False: WfBooster = False: Wfall = False: ShDescent = False: PcLay = False: SpLay = False
End If
End Function
Any and all help with this likely to be easy question is greatly appreciated. Thanks.
I'm writing a VBA app to open a simple dialogue with Checkboxes and Option buttons which settings determine the electrical and plumbing schematic block is to be inserted into a drawing. Then, the correct AUTOLISP command is compiled and output to the Command line while exiting the dialogue.
This all works fine until I need to check if two or more statements are true at the same time. I tried to use a if, and, then, elseif, else statement but is doesn't seem to recognize the statement at all? here is an example:
Function GetEQ()
If SpaOnly And Raised = True Then
EQ$ = "RSWV"
ElseIf PoolSpa And PCC = True Then EQ$ = "PCS"
ElseIf PoolOnly And PCC = True Then EQ$ = "PC2"
ElseIf SpaOnly And Vac = True Then EQ$ = "SWV"
ElseIf PoolOnly = True Then EQ$ = "NP"
ElseIf SpaOnly = True Then EQ$ = "SWV"
ElseIf PoolSpa = True Then EQ$ = "PAS"
Else
PoolOnly = False: SpaOnly = False: Raised = False: Vac = False: PVal = False: NoBooster = False: PCC = False: Att = False: Sepr = False: SpaB = False: TwoSkims = False: Frog = False: Salt = False: DiChlor = False: WfBooster = False: Wfall = False: ShDescent = False: PcLay = False: SpLay = False
End If
End Function
Any and all help with this likely to be easy question is greatly appreciated. Thanks.