473,472 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Im dumb. please help.

22 New Member
For some reason I cant get the most basic operations to calculate in my program. Im sure its something painfully stupid but here it is.


Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. Dim iLogFail As Integer
  3. iLogFail = 0
  4. End Sub
  5.  

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command8_Click()
  2. If iLogFail = 3 Then
  3.     MsgBox "works"
  4. End If
  5.  
  6. iLogFail = iLogFail + 1
  7. End Sub
  8.  

it doesnt work. and my var isnt initializing. it should be 0 but its empty. im going crazy here what am i doing wrong?
Jul 7 '06 #1
2 1452
sashi
1,754 Recognized Expert Top Contributor
Hi there,

in order to reuse the same variable again and again make sure u declare and the variable in the general declaration area or in a module file.. good luck my fren.. :)

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command8_Click()
  2.   If iLogFail = 3 Then
  3.     iLogFail = iLogFail + 1
  4.     MsgBox "works"
  5.   EndIf
  6. End Sub
  7.  
Jul 8 '06 #2
BSOB
77 New Member
sashi be right but, being me, i have to give some explanation. This is all about scope. where a variable can be use depends on where it is dimentioned. putting a variable in a subroutine (like your form_load) says "i want to use this varaible, but only in this subroutine". putting it in general declarations says "i want to use this varaible, but only on this form", putting a variable in a module says "i want to use this variable anywhere in my project no matter how many forms i have." trying to access a variable outside of its scope will create a new varaible. to avoid mistakes like this, type "option explicit" at the top of your general declarations and it will tell you when a variable is undefined. handy for finding simple mistakes like this.
Jul 15 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Raymond Arthur St. Marie II of III | last post by:
very Very VERY dumb ? about the new Set( ) 's Please be kind and read this like you know I've been up 33-34 hours reading PEP's but... Doc\ref 2.6 Delimiters show's three unused characters "@...
2
by: Marion | last post by:
I would like to go on record to say that I think not having the Printer collection in .Net is dumb. The only help tells me that I should use the Print Dialog. Well, I don't want to. Programming is...
2
by: InvisibleMan | last post by:
Hi, I feel a little dumb for asking this (considering im writing TSQL) but there doesn't seem to be any definitive answers on the search engines... Okay I understand that if you open the ADO...
11
by: dhnriverside | last post by:
Hi peeps Ok, so I thought I'd have a go at making a console app in VS2k5... I haven't written any windows apps for years, let alone dos apps (been web programming) and I've hit a dumb error... ...
5
by: gjdagis | last post by:
This is my first day trying to learn PHP and ALREADY I'm stumped. I bought the SAMS Guide toPHP. MySQL, and Apache Book. On page 18 it tells me to create a file called phpinfo.php. HOW do I create...
16
by: CMM | last post by:
Is it me or has anyone noticed that F1 is really dumb in VS2005. Since VB3 I have been able to click F1 on an ambiguous method in code and the IDE automatically determines the type based on the...
3
by: diffuser78 | last post by:
I am a newbie to C++. Following is my thinking about C++ ..correct me if I am worng. C++ has a standard compiler and MS Visual Studio C++ is just an IDE for the standard C++ compiler or there is...
4
by: rodchar | last post by:
hey all, i've read wikipedia's version and still kinda fuzzy, can someone please give me a dumb down version of imperative vs declartive programming? thanks, rodchar
4
by: theapeman | last post by:
Sorry to bore everyone with this question, which I'm sure is the equivalent of "Please help! What letter comes between C and E in the alphabet?" but seriously, if you really didn't know that, I don't...
2
by: When You Need to Tell Someone | last post by:
I saw a javascript popup that I just loved, and I'd like it on my new website. I think it involved CSS, but I have no clue. It was a rollover popup, with a "pop" sound, and the image that popped...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.