-
August 18th, 2014, 11:40 AM
#1
Dim my variables
I was just wandering should I dim my variables in a form? If I don't, it still does the calculation but should I do it anyway?
-
August 18th, 2014, 12:48 PM
#2
Re: Dim my variables
DIM statements are used to control the TYPE of the variable. Non-DIM variables are OBJECTS in VB6
-
August 18th, 2014, 03:21 PM
#3
-
August 18th, 2014, 11:49 PM
#4
Re: Dim my variables
You should always Dim all variables.
You should also have the little box checked under the editor properties to require variable declaration also known as Option Explicit.
Not dimming your vars leads to poor performance and makes it much harder to debug your code and can cause some unexpected results.
Always use [code][/code] tags when posting code.
-
August 19th, 2014, 06:48 AM
#5
-
August 19th, 2014, 06:52 AM
#6
Re: Dim my variables
But how do I do that? For example 'dim a as integer' Is that correct?
-
August 19th, 2014, 09:42 AM
#7
Re: Dim my variables
Yes though you should use descriptive names for your variables
Code:
Option Explicit
Dim Qty As Integer
Dim Cost as Currency
Dim PartNumber as String
You can also place more than one on a line like
Code:
Dim Qty as Integer, Cost as Currency
Always use [code][/code] tags when posting code.
-
August 19th, 2014, 04:34 PM
#8
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
|