473,399 Members | 3,888 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,399 software developers and data experts.

Accumulating Sum in Label

63
Look at the following code:

Expand|Select|Wrap|Line Numbers
  1. Dim LaptopPrice As Integer
  2. Dim HDDPrice As Integer
  3.  
  4. 'Prices of Laptops
  5. Const LongitudePrice As Integer = 200
  6. Const PerspironPrice As Integer = 350
  7. Const IncisionPrice As Integer = 500
  8.  
  9. 'Prices of Hard Drives
  10. Const 40GBDrivePrice As Integer = 0
  11. Const 80GBDrivePrice As Integer = 80
  12. Const 120GBDrivePrice As Integer = 120
  13.  
  14. If optLongitude.Value = True Then
  15.   LaptopPrice = LongitudePrice
  16. ElseIf optPerspiron.Value = True Then
  17.   LaptopPrice = PerspironPrice
  18. ElseIf optIncision.Value = True Then
  19.   LaptopPrice = IncisionPrice
  20.  
  21. ElseIf opt40GBDrive.Value = True Then
  22.   HDDPrice = 40GBDrivePrice
  23. ElseIf opt80GBDrive.Value = True Then
  24.   HDDPrice = 80GBDrivePrice
  25. ElseIf opt120GBDrive.Value = True Then
  26.   HDDPrice = 120GBDrivePrice
  27. Else
  28.   MsgBox "Please make a selection", vbExclamation, "Make Selection"
  29. End If
Now I want to display the total price in a label, once the user selects a particular option button. For example if longitude is selected, the label should show 200, then if a 120GB drive is chosen, the total should display 300, and so on. How do I concatenate the two integers in a label?

I tried:

lblSum.Caption = LaptopPrice + HDDPrice
lblSum.Caption = LaptopPrice & HDDPrice

None of these work

Please help, thanks in advance!
Nov 21 '07 #1
1 2127
Killer42
8,435 Expert 8TB
Since you're dealing with numbers, I seriously doubt that concatenation is what you intend. More likely you want to add the numbers.

In any case, this code can only ever set LaptopPrice or HDDPrice, not both. Because the whole If...ElseIf... structure makes them mutually exclusive. Keep in mind that since they are all "else" clauses, as soon as one test is true, everything else will be skipped.

Also, please don't stop at "it doesn't work". Give us details of what did or didn't happen unexpectedly.
Nov 22 '07 #2

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

Similar topics

2
by: Xerxes | last post by:
Hi, can you tell me how I can make a <label> hidden? I have hidden the field after the label: var M_Hide = isNS4?'hide':'hidden'; var M_Show = isNS4?'show':'visible'; ..... <label...
3
by: TR | last post by:
Is it possible with CSS to prevent this wrapping alignment with a checkbox with a nested label? This is the label of the checkbox that wraps beneath it I'd prefer it looked like...
4
by: Stuart Norris | last post by:
Dear Readers, I am attempting to draw box around some text using unicode on multiline label. The label is forty characters wide and 12 lines deep. I have been trying to draw a box around text...
31
by: jcrouse | last post by:
Is there a quick and easy way to change the color of a label controls border from the default black to white? Thank you, John
20
by: sucaba.r | last post by:
I've got a table that contains a column of accumulating uptime data that looks similar to this: 239.13 239.21 239.30 239.38 239.46 239.55 0.35
1
by: Manoj Mittal | last post by:
I have created the Dynamic control in asp.net c# like for (int i = 1; i <= 5; i++) { Label label = new Label(); label.ID = "Label" + i; label.Text = "Label"+i; form1.Controls.Add(label); }
0
by: Kevin McKinley | last post by:
Below i've put the code for a program that i wrote. I need help on lines 384-403. If you run this program you will notice on the first tab when have it produce an answer the $ is surrounded with...
0
by: Guilherme Polo | last post by:
On Wed, Sep 3, 2008 at 8:57 PM, Kevin McKinley <kem1723@yahoo.comwrote: Come on.. "help on lines 384-403", that is not a good way to look for help. You are supposed to post some minimal code that...
9
by: =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post by:
Hi all I have a MDI Container Form, with one label control on the Background of this container form. When I now open a child form, this form is behind the label ... and this looks ugly ... :-))...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
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
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...

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.