Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Question about Using Dim
Sandra Truax 
         
4 years ago
In several videos,  Richard said you could NOT use
   Dim a, b, c As Long
   Or
   Dim a, b, c as string
However I was watching another instructor and he did it in his video so I tried it as follows and they both worked. Is there a reason why this is bad programming and I shouldn't do it?

    Dim a, b, c As Long
        a = 5
        b = 3
        c = a + b
    MsgBox c

    Dim a, b As String
        a = "Mr."
        b = "Smith"
    MsgBox a & " " & b
Kevin Robertson  @Reply  
           
4 years ago
Using your example:

Dim a, b As String
a is a Variant, b is a String

To declare both a and b as String you must declare each variable as the specific type.
Dim a as String, b as String

If you know the type of data is always going to be a String, declare it as a String.
If you are unsure what data type will be returned, declare it as a variant (you can convert it later, if needed).
Richard Rost  @Reply  
          
4 years ago
Any video in which you might see that is either (a) a goof on my part, or (b) I'm trying to illustrate how Dim works.

If the topic of the video isn't Dim itself, it's probably a goof. :)
Richard Rost  @Reply  
          
4 years ago
Oh wait... you said ANOTHER instructor did that. OK... that brings up some other thoughts...

(a) why are you cheating on me?
(b) that instructor either goofed, doesn't know better, or is lazy (or all three)

LOL. I kidding. :)

Yes... that will WORK as in it won't throw a compile-time error, but there are several problems with having those a Variants when you're expecting them to be strings.
Sandra Truax OP  @Reply  
         
4 years ago
Richard, I'm so ashamed I cheated on you!  Won't happen again LOL.  Free isn't worth it if what he's says is misleading! That's why I asked the question becaused I knew I could trust y'all and the answer you would give me. Thank you Kevin for explaining so that I could understand why I shouldn't do that.
Richard Rost  @Reply  
          
4 years ago
Yeah, be careful what you read/watch out there. Lots of misinformation. It looks like this guy (the other video you watched) just made a lazy mistake that I'm guilty of from time to time myself. But I've seen some tutorials where people give CLEARLY wrong information. I've called a couple of them out on it. I've got a nasty-gram I need to write to one author who is telling people to use OneDrive or DropBox to share an Access database. NO! NO!

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/8/2026 9:32:00 PM. PLT: 0s