|
-
Jan 26th, 2010, 07:25 AM
#1
Thread Starter
New Member
change command button values counter
Hi, This is my first thread here.
I'm sitting in college writing a program for a virtual mobile phone, just come across the need to change the value of a command button based on how many times I press it. AKA: The text message system.
pressing 2 twice = B pressing it once = A.
Looking forward for any advice. Will just use my 'counter' deal just now.
-
Jan 26th, 2010, 08:09 AM
#2
Re: change command button values counter
Make use of a Static variable, then increment it. If it's value is 1, print A, if its value is 2 then print B.
VB.NET MVP 2008 - Present
-
Jan 26th, 2010, 08:24 AM
#3
Re: change command button values counter
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Jan 26th, 2010, 09:30 AM
#4
Re: change command button values counter
Aah, now I see what you mean, duh.. dumb Hannes dumb ! LOL
VB.NET MVP 2008 - Present
-
Jan 26th, 2010, 09:41 AM
#5
Re: change command button values counter
Wait a minute. I was on the right track 
Look here :
Code:
Private Sub Command1_Click()
Static iClicked As Integer
Dim sbut As String
iClicked = iClicked + 1
Select Case iClicked
Case 1
sbut = "A"
Case 2
sbut = "B"
Case 3
sbut = "C"
Case Is > 3
iClicked = 0
End Select
Text1.Text = sbut
End Sub
If you were to use the same logic here for each button, it would work 
Yes, some tweaking is still required, but the rough framework would be there.
VB.NET MVP 2008 - Present
-
Jan 26th, 2010, 02:52 PM
#6
Re: change command button values counter
HanneSThEGreaT Code modifed.
Code:
Dim iClicked As Integer
Private Sub Command1_Click()
iClicked = iClicked + 1
Select Case iClicked
Case 1
Text1.Text = "A"
Case 2
Text1.Text = "B"
iClicked = 0
Case Else
iClicked = 0
End Select
End Sub
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
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
|