473,287 Members | 1,447 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Im dumb. please help.

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 1449
sashi
1,754 Expert 1GB
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
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.