473,395 Members | 1,692 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,395 software developers and data experts.

Using variable in button to give value to label

I have tried this on a MacBook with Parallels running Windows 7, and on a Vaio desktop running Windows 7, but both with Visual Studio 2012:

I am trying to use different buttons to assign different values to a variable.
There are 2 variables using different buttons to assign them.
These variables are being added together to assign value to a label.

I believe my error is in my syntax but I have not found out how to use a button to set the value for a variable.

I get no error codes, I just do not get a result in my final label. It stays blank.


Here is a chunk of my code:

Expand|Select|Wrap|Line Numbers
  1. Public Class frmLunchCombos
  2.  
  3. ‘I went ahead and defined my variables
  4.     Dim dblSandwichCost As Double
  5.     Dim dblSoupCost As Double
  6.  
  7.  
  8. 'Click TomatoBasil
  9.     Private Sub btnTomatoBasil_Click(sender As Object, e As EventArgs) Handles btnTomatoBasil.Click
  10.  
  11. ‘I mean for this to set SoupCost to the value 2.49        
  12. dblSoupCost = 2.49
  13.  
  14.      End Sub
  15.  
  16.  
  17. 'Click ClassicTurkeyBreast
  18.     Private Sub btnClassicTurkeyBreast_Click(sender As Object, e As EventArgs) Handles btnClassicTurkeyBreast.Click
  19.  
  20. ‘I mean for this to set SandwichCost to the value 3.49
  21.  
  22.         dblSandwichCost = 3.49
  23.  
  24.     End Sub
  25.  
  26.  
  27.  
  28. Private Sub lblCalcSubtotal_Click(sender As Object, e As EventArgs) Handles lblCalcSubtotal.Click
  29.  
  30.       ‘I made dblValue for easy formatting of the final label
  31.  
  32.         Dim dblValue As Double
  33.  
  34.  ‘Value= SoupCost (which would be assigned to 2.49 after clicking Tomato Basil) + SandwichCost (which would be assigned to 3.49 after clicking ClassicTurkeyBreast)
  35.  
  36.         dblValue = dblSoupCost + dblSandwichCost
  37.  
  38.  ‘And then convert Value to a currency-formatted string
  39.  
  40.         lblCalcSubtotal.Text = dblValue.ToString("C")
  41.  
  42.     End Sub
  43.  
Many thanks in advance! I really want to understand this and I feel like it's something simple.
Mar 19 '15 #1
2 2311
Dear Friend,
Your problem invoked a hornets nest in my programming world.I was doing C-Pad programming(cmd & notepad)
and suddenly i found your problem has creeped in to my C-Pad also.No textbox,listbox or label is responding
to button click.It was working easily for me all these days.Microsoft uploaded many updates recently(just 3 days since)
They must have screwed up something.Anyway,i did your project in visual studio express 2013 and uploaded to
the URL:-(given below)
http://www.filehosting.org/file/deta.../Violet469.rar
I used a listbox instead of label.No problem.Even Label and Textbox will work fine.Now i will have to analyse what went
wrong in my C-Pad style.I have uploaded many projects to the following URL:-(It includes VB.Net and WPF-with-VB.Net).
http://www.dreamincode.net/forums/to...&#entry2124851
Do
try out those and tell me whether they work in your Computer.I have windows 8.1.
Venkatraman
Mar 21 '15 #2
Dear Friend,
I worked further and made your project as per your expectations.I also found out that It is not Microsoft who screwed up,But it is me.
I actually had a simple error which i overlooked.Anyway it helps me to blame Microsoft first and then on retrying locate the blame on myself.
(Not surprising considering my age-68+)This project is named Project469 and uploaded to URL:-(It is in C-Pad style)

http://www.filehosting.org/file/details/478305/Project469.rar[/url]

You have to call the compiler from your cmd window as given below.First place the two .vb files(Violet2.vb and Violet22.vb) in a folder
-New folder(you can name it appropriately).
The compiler calling is:-

path=%path%;c:\windows\microsoft.net\framework\v4. 0.30319
VBC /OUT:Violet2 /T:winexe C:\Users\.......\Desktop\Folder\Violet2.vb
VBC /OUT:Violet2 /T:winexe C:\Users\.......\Desktop\Folder\Violet22.vb C:\Users\VEKATRAMAN\Desktop\New folder\Violet2.vb
Violet2

NOTE:The dotted portion is particular to your computer.Mostly it will be your name.Change the New folder to whatever you want.
This project is exactly what you wanted-with ListBox as a bonus addition.
Mar 21 '15 #3

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

Similar topics

1
by: Jerim79 | last post by:
I have a simple 3 page registration form. One form, one "data validation" script and one "insert into database" script. The customer bounces back and forth from the form to the verification script...
8
by: kj | last post by:
Is there a simple way to decouple the value attribute of a submit button from the text that actually gets displayed on it? In principle, what I'm looking for is something like <input...
1
by: mrbadboy | last post by:
Hi, I need to submit multiple forms with using single button. I've mentioned my code below. <? if(isset($_POST)){ print_r($_POST); } ?> <script type="text/javascript">
1
by: ragonz | last post by:
Hi, i'm kind of newbie in java programming. Now, i'm working on my task, n i hav a problem in using variable from other method. Here goes the code.. import java.awt.*; import java.awt.event.*;...
1
by: rjlorenzo | last post by:
Good Day, I just need help on my programming. I would like to try to retrieved/edit the data i've save using radio button and want it to displayed on radio button for editing or changing the...
2
by: JWest46088 | last post by:
I'm making a contact form, and I keep getting two errors when I try previewing it in a web browser. ReferenceError: Error #1065: Variable Button is not defined. ReferenceError: Error #1065:...
1
by: imtiyazrdl | last post by:
Hi I need customer can select delivery day name (Saturday and thus day ) using radio button and radio button is value store in order table or any new table and also mansion this day value in order...
2
Claus Mygind
by: Claus Mygind | last post by:
I have a method in a class that updates one of 7 variables/properties in the class. I would like to reduce the "switch" command to one line by using a variable variable, but I don't seem to be able...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
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...
0
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...

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.