Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Easy One _Unfortunately Not For Me

Posted on 2000-03-17
9
Medium Priority
?
171 Views
Last Modified: 2010-05-02
Hi,
I Adopted a project and the code of someone who cannot help me, that appears to keep track of the contents of a textbox.
-----------------------
If (txtMentors.Text = "") Then
 MsgBox "The Mentors field is left blank"
 FieldTrack% = 1
End If
-----------------------

I cannot figure out this use of a % in a variable name. I tried declaring:
--------------------------
Dim FieldTrack% as Integer
--------------------------

, that is not working. What is the % all about. Thanks.

diek
 
0
Comment
Question by:diek_nf
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 1

Accepted Solution

by:
prozak earned 12 total points
ID: 2627978
% is a way to tell VB that the variable is of type integer (you can do the same thing with a $ to be a string). This is a hold over from BASIC. You can remove the % sign and not worry about it.

Dim FieldTrack As Integer

FieldTrack = 1

That should work fine.
0
 
LVL 3

Expert Comment

by:paulstamp
ID: 2627984
The % is simply a declaration character stating the FieldTrack is an integer variable.

Personally I avoid using such symbols :

Dim FieldTrack as Integer

and remove the % from
FieldTrack% = 1
0
 
LVL 3

Expert Comment

by:paulstamp
ID: 2627987
Sorry prozak... your answer appeared as I was typing.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:mcrider
ID: 2627989
the % says that the variable is an integer... You use the % if you're not going to declare the variable using the "Dim" statement.

If you are going to use the "Dim" statement, don't use the %

For example:

   Dim FieldTrack as Integer

Then anywhere in the sub where you reference "FieldTrack%", change it to "FieldTrack"


Cheers!®©
0
 
LVL 1

Expert Comment

by:prozak
ID: 2628005
That's OK paul, I see I was only 1 minute ahead of you :)
0
 
LVL 3

Expert Comment

by:paulstamp
ID: 2628009
paulstamp changed the proposed answer to a comment
0
 

Author Comment

by:diek_nf
ID: 2628058
prozak,
I feel like a bit of a dummy but what the hell. That works perfectly.
diek
0
 

Author Comment

by:diek_nf
ID: 2628067
Sorry,
I was a bit quick. Thank you to everyone who replied, and darn speedy to boot. Have a good day of programming.
diek
0
 
LVL 1

Expert Comment

by:prozak
ID: 2628097
Nobody is a dummy here...
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question