how to declare this variable

icemonster

Registered User.
Local time
Today, 09:45
Joined
Jan 30, 2010
Messages
502
how should i declare my variable vbresponse and strmsg (i think this one is string :P)?:

Code:
strMsg = "Are you sure you want to add these classes a required course for this Licensure Program?"
vbResponse = MsgBox(strMsg, vbYesNo + vbDefaultButton1 + vbQuestion, "Register program with student?")
If vbResponse = vbYes Then
 
The vbresponse variable will need to be defined as a variant.

Just use:

Dim vbresponse

That is all you need.
 
I believe declaring it as "Single" is more efficient and requires much less memory to store.

Dim vbresponse as Single
 
Or you don't even have to declare it:

Use this instead:
Code:
strMsg = "Are you sure you want to add these classes a required course for this Licensure Program?"
If MsgBox(strMsg, vbYesNo + vbDefaultButton1 + vbQuestion, "Register program with student?") = vbYes then
 
To be specific (per the Access Help file), the MsgBox function returns an Integer. So to be precise you would need to declare the variable as an Integer. However, most of us simple declare it as a variant.
 
To be specific (per the Access Help file), the MsgBox function returns an Integer.
Incorrect. AFAIK all vb constants are datatype Long

Copy this into the Immediate Window and hit return to confirm.
Code:
? TypeName(vbYes)

So to be precise you would need to declare the variable as an Integer.
Integer will work in this case (and most if not all) since Integer is a subset of Long and I have yet to see constants above 32767. However they might exist so I would always use Long.

However, most of us simple declare it as a variant.
Not me and I expect most others too. Why would anyone declare a Variant when its actual type is known?
 

Users who are viewing this thread

Back
Top Bottom