There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
blue screen boot bsod computer connection crash css dell display driver drivers email error ethernet excel firefox firefox 3 game hard drive hardware internet internet explorer itunes laptop lcd malware monitor network networking outlook outlook 2003 outlook express partition password printer problem problems router security slow sound sprtcmd.exe trojan usb video virus vista windows windows xp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
IsEmpty in VB6


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
cj_white's Avatar
Senior Member with 335 posts.
 
Join Date: Oct 2001
27-Mar-2005, 04:43 PM #1
IsEmpty in VB6
hey guys i am learning VB6 and messing aroung with some of the functions. i am trying to use the isempty() function but i am getting 'Wrong # of argument or invalid property assignment. this is what i have so far

Private Sub cmdResult_Click()
Dim strFname As String * 50
Dim strLname As String * 50

strFname = Me.txtFname.Text
strLname = Me.txtLname.Text

If IsEmpty(strFname, strLname) = True Then MsgBox "you have not filled out all fields"
ElseIf IsEmpty(strFname, strLname) = False Then MsgBox "Hello " & strFname & " " & strLname & "!" & " How are you today?"

End Sub

Private Sub Form_Load()

End Sub

i'm not sure if there is a problem with the way i have the IsEmpty() set up or maybe i am using the if, then , else statement incorrectly. basicly i have 2 text boxes where you put your first and last name and it is supposed to check to see if they are filled out. thanks in advance
RedAxl's Avatar
Member with 47 posts.
 
Join Date: Nov 2004
Experience: OpenROAD Programmer
27-Mar-2005, 10:00 PM #2
Hi,

Quote:
IsEmpty returns TRUE if the variable is uninitialized, or is
EXPLICITLY SET TO EMPTY; otherwise, it returns FALSE.
FALSE is ALWAYS returned if expression contains MORE THAN ONE variable.
IsEmpty ONLY returns meaningful information for VARIANTS.
It is simpler, direct, and safer to test empty variable strings against blank ("") strings.

Change the following lines:
Quote:
If IsEmpty(strFname, strLname) = True Then MsgBox "you have not filled out all fields"
ElseIf IsEmpty(strFname, strLname) = False Then MsgBox "Hello " & strFname & " " & strLname & "!" & " How are you today?"
Into:
Quote:
If strFname = "" OR strLname = "" Then
MsgBox "you have not filled out all fields"
Else
MsgBox "Hello " & strFname & " " & strLname & "!" & " How are you today?"
End If
Also, consider TRIMming your string variables.


Red
cj_white's Avatar
Senior Member with 335 posts.
 
Join Date: Oct 2001
28-Mar-2005, 05:38 PM #3
thanks for replying. i made the changes you have suggested. I am now getting 'else without if' compile errors. i have the 'end if' at the end of the code. any other suggestions

Private Sub cmdResult_Click()
Dim strFname As String
Dim strLname As String

strFname = Me.txtFname.Text
strLname = Me.txtLname.Text

If strFname = "" Or strLname = "" Then MsgBox "you have not filled out all fields"
Else: MsgBox "Hello " & strFname & " " & strLname & "!" & " How are you today?"
End If
End Sub
RedAxl's Avatar
Member with 47 posts.
 
Join Date: Nov 2004
Experience: OpenROAD Programmer
28-Mar-2005, 07:58 PM #4
Just place the
Quote:
MsgBox "you have not filled out all fields"
on the next line. It will make your code more readable too.

Also, you can ommit the optional COLON ":" after the ELSE.

Quote:
If strFname = "" Or strLname = "" Then
MsgBox "you have not filled out all fields"
Else
MsgBox "Hello " & strFname & " " & strLname & "!" & " How are you today?"
End If
Red
cj_white's Avatar
Senior Member with 335 posts.
 
Join Date: Oct 2001
28-Mar-2005, 08:47 PM #5
that worked. thanks for all your help. is that just the syntax for the if, then, else statement? some things i noticed you can't do that with because as soon as you hit enter to move it to the next line you get a compiler error. i am trying to learn this after i have already learned PHP and i have found it's hard to keep them straight in my head. once again thanks for the help
RedAxl's Avatar
Member with 47 posts.
 
Join Date: Nov 2004
Experience: OpenROAD Programmer
28-Mar-2005, 11:00 PM #6
It is the setting of Auto Syntax Check option that causes the immediate error/warning.

To set/unset the Auto Syntax Check option

From the Tools menu, select Options, and click the Editor tab on the Options dialog box.


Select Auto Syntax Check (Check/Uncheck).



Red
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 09:25 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.