Why should I use the DIM statement in VBA or Excel

0 votes

So there is a question on what DIM is, but I can't find why I want to use it.

As far as I can tell, I see no difference between these three sets of code:

'Example 1
myVal = 2

'Example 2
DIM myVal as Integer
myVal = 2

'Example 3
DIM myVal = 2

If I omit DIM the code still runs, and after 2 or 3 nested loops I see no difference in the output when they are omitted. Having come from Python, I like to keep my code clean*.

So why should I need to declare variables with DIM? Apart from stylistic concerns, is there a technical reason to use DIM?

* also I'm lazy and out of the habit of declaring variables.

Apr 7 in Database by Edureka
• 9,700 points
10 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Database

0 votes
1 answer

Should I use != or <> for not equal in T-SQL?

Most of the existing databases support != Databases that ...READ MORE

answered Feb 14 in Database by Vaani
• 5,240 points
40 views
0 votes
1 answer

What is the syntax of USE statement in MySQL?

The USE statement is used to mention ...READ MORE

answered Nov 27, 2018 in Database by Sahiti
• 6,360 points
276 views
0 votes
1 answer

what is the syntax of OR statement in MySQL?

The OR operator displays those records which ...READ MORE

answered Dec 1, 2018 in Database by Sahiti
• 6,360 points
199 views
0 votes
0 answers

How would I use excel to generate a large update sql statement?

I know there's a way to have ...READ MORE

Mar 30 in Database by Edureka
• 9,700 points
27 views
0 votes
0 answers

How to loop in excel without VBA or macros?

Is it possible to iterate (loop) a ...READ MORE

Mar 30 in Database by Edureka
• 9,700 points
73 views
0 votes
1 answer

How do I display a ratio in Excel in the format A:B?

Try this formula: =SUBSTITUTE(TEXT(A1/B1,"?/?"),"/",":") Result: A B ...READ MORE

answered Apr 1 in Database by Edureka
• 8,820 points
27 views
0 votes
1 answer

How do I split a cell in Excel into two or more where they are divided horizontally?

Table cells should be combined. To make a ...READ MORE

answered Apr 6 in Database by Edureka
• 8,820 points
27 views
0 votes
1 answer

Why is not preferable to use mysql_* functions in PHP?

The reasons are as follows: The MySQL extension: Does ...READ MORE

answered Sep 7, 2018 in Database by DataKing99
• 8,240 points
319 views
0 votes
1 answer

IN vs OR in the SQL WHERE Clause

I assume you want to know the ...READ MORE

answered Sep 24, 2018 in Database by DataKing99
• 8,240 points
435 views
0 votes
1 answer

Excel: Highlighting duplicates with exact matches

To enter the Advanced Filter dialogue box, ...READ MORE

answered Mar 24 in Database by Edureka
• 8,820 points
23 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP