473,569 Members | 2,879 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please help me with addition to variable

2 New Member
Please teach me how to do this the right way in vb6 or vb08. (preferbably vb6)

What i want is to increase the value of Text1.text by 1 every time i click it. But with this code, Text1.text remains as 1 so matter how many times i click it.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.  Dim cap As Integer
  3. cap = Val(Text1.Text)
  4. End Sub
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2. cap = cap + 1
  3. Text1.Text = cap
  4. End Sub
May 16 '09 #1
2 1639
debasisdas
8,127 Recognized Expert Expert
try using Static instead of Dim.
May 18 '09 #2
QVeen72
1,445 Recognized Expert Top Contributor
Hi,

In Command1_Click, just change the code to :


Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2.     Text1.Text = Val(Text1.Text) +1
  3. End Sub
  4.  
Remove code from Form_Load

Regards
Veena
May 18 '09 #3

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

Similar topics

8
6472
by: Matt | last post by:
Hello, How can I do mathematical addition of strings in C++? As in: string one; string two; string three; three = one + two;
34
16635
by: Andy | last post by:
Hi, Are 1 through 4 defined behaviors in C? unsigned short i; unsigned long li; /* 32-bit wide */ 1. i = 65535 + 3; 2. i = 1 - 3; 3. li = (unsigned long)0xFFFFFFFF + 3; 4. li = 1 - 3;
8
2574
by: Roger Leigh | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 A lot of functions use const pointer arguments. If I have a non-const pointer, it is transparently made const when I pass it to the function, e.g. char * -> const char *. However, this does not appear to work when I add another level of indirection: void test1 (char **value) {}
10
1031
by: | last post by:
Hi I have trying to solve this but I can't understand why it's not working. I want to cast a variable dynamically with a type that I pass truogh a string. I am receiving a value and want to check if the type is correct before saving it to the XML. I am getting the Type from xsd and pass this to a function to convert the newvalue to the...
36
2079
by: Cap'n Ahab | last post by:
I have used VB3 - VB6, so learning all this OO stuff is reasonably new to me (although I looked at Java a few years ago). Anyway, I thought I would write a small class to begin with, with a property and 2 methods, along with a constructor (where you use New(), I think, yes?). So, I decided to create a class that represents a die, which can...
5
1604
by: gene.ellis | last post by:
Hello everyone, Put simply we have recently been the victims of a malicious hacker because we were not aware of the dangers of SQL injection. Now, I am adding addition validation to my forms and also GET variables (we are using PHP). Does anyone have any good techniques for the kind of validation I should be using to avoid SQL injection? I...
3
2177
by: snow.carriers | last post by:
Let me first state that I'm using Borland Turbo C++, it's relatively old so the new string methods won't work. Anyways, first I'm trying to collect a line of a string (with numbers, letters, dashes) into each variable. For just numbers, it's relatively easy: ifstream fout("s1.in"); for (a=0; a<17; a++) { fout >> data; cout << data <<...
5
2266
by: Paul | last post by:
Why is the addition here adding the number as a string but the subtraction works fine? function boxchange(box) { iv= dbform.ut.value if (box.checked == true) { iv = iv - box.value } else { iv = iv + box.value
62
2677
by: vubaboota | last post by:
I HAVE SOME SERIOUS PROBLEM , HOW TO MAKE A PROGRAM IN C Q1: Write a program using malloc function. In which you take input from user and allocate memory equal to square of this number. Which multiply numbers and draw a table in the following format? Hint: User enters 3 then program allocates equal to 9 integer memories. Output:1
0
7619
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7681
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7983
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5514
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5228
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3662
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1229
muto222
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.