|
-
Jan 14th, 2005, 04:21 PM
#1
Thread Starter
Member
Else Without If
i know this is a really easy thing to fix, but i cant figure it out
I keep getting the method Else Without If, how can i fix it
VB Code:
If showf.Text = "" Then MsgBox ("You Cannot Leave The Show Command Empty")
ElseIf Hidef.Text = "" Then MsgBox ("You Cannot Leave The Hide Command Empty")
ElseIf Endf.Text = "" Then MsgBox ("You Cannot Leave The End Program Command Empty")
ElseIf Hidef.Text = "" Then MsgBox ("You Cannot Leave The Open Command Empty")
Else: Big Mess of Code
End If
Thanks
ParadoX
-
Jan 14th, 2005, 04:23 PM
#2
Hyperactive Member
Re: Else Without If
VB Code:
If showf.Text = "" Then
MsgBox ("You Cannot Leave The Show Command Empty")
ElseIf Hidef.Text = "" Then
MsgBox ("You Cannot Leave The Hide Command Empty")
ElseIf Endf.Text = "" Then
MsgBox ("You Cannot Leave The End Program Command Empty")
ElseIf Hidef.Text = "" Then
MsgBox ("You Cannot Leave The Open Command Empty")
Else
'Big Mess of Code
End If
When there's a statement on the same line as the Then, that means something different to VB.
-
Jan 14th, 2005, 04:29 PM
#3
Re: Else Without If
Also, the colon character ':' when used that way is designating a carraige return, or such.
VB Code:
For i = 1 to 10 : MsgBox i : Next
But its bad coding to use that style.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 14th, 2005, 06:45 PM
#4
Re: Else Without If
Better is:
VB Code:
Select Case True
Case showf.Text = ""
MsgBox ("You Cannot Leave The Show Command Empty")
Case Hidef.Text = ""
MsgBox ("You Cannot Leave The Hide Command Empty")
Case Endf.Text = ""
MsgBox ("You Cannot Leave The End Program Command Empty")
Case Hidef.Text = "" 'BTW do you realize this is the same as the one above
MsgBox ("You Cannot Leave The Open Command Empty")
Case Else
'Big Mess of Code
End Select
Also a user of your program could type a couple of spaces in one of your textboxes and that would pass your edit so you might want to change all of them like this one
VB Code:
Case Trim(showf.Text) = ""
-
Jan 14th, 2005, 08:34 PM
#5
Re: Else Without If
There is one very interesting thing I noticed recently:
this sort of coding style (single line with colon) appears on our forum very frequently - I wonder if people that ask are all having the same instructor ???
Just curious ...
-
Jan 14th, 2005, 10:25 PM
#6
Re: Else Without If
teacher being slick, so he can find copycats, prolly. could be he doesn't know the difference, but in this day and age, I would hope that isn't the case. (it was almost 30 years ago when I was in school)
-
Jan 17th, 2005, 01:26 AM
#7
Re: Else Without If
iParadox
Try changing
Else: Big Mess of Code
to
Else
Big Mess of Code
or better yet
Else
Call Big Mess of Code
But for better coding I would suggest MartinLiss's Case Statement.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|