Solved

Visual Basic simple Question

Posted on 2004-04-12
7
195 Views
Last Modified: 2013-11-25
I have a question that has frustrated me while doing my homework. We do not get grades on it. I am 58 and taking it as a 'recreational' subject with the intention to know as much as possible.

I have a txtBox where one enters a Number. I then have a Summary Box which supposed to take the contents of the box and plases it on command into a lbl box. The intention is to accumulate numbers in the Summary box. For some reason it does not work. I can accumulate numbers from a lblbox to a lbl Box but from a txt Box to a lable summary box results in a blank entry.

The 'Sales' commands work as shown below:

Dim curWeeklySales As Currency
Dim SummaryWeeklySales1 As Currency
curWeeklySales = Val(txtWeeklySales)
lblSummaryWeeklySales1.Caption = FormatNumber(curWeeklySales) _
+ Val(lblSummaryWeeklySales1.Caption)

The following where out of frustration gave the cammand a number, resulted in a blank.

Dim curSummaryWeeklyPay1 As Currency
  lblSummaryWeeklyPay1.Caption = 10000 This results in a blank
 lblSummaryWeeklyPay1.Caption = Val(LblPay1.Caption) This also results in a blank

gonzal13(Joe)

0
Comment
Question by:gonzal13
7 Comments
 
LVL 11

Expert Comment

by:bingie
ID: 10810199
>>Dim curSummaryWeeklyPay1 As Currency
    lblSummaryWeeklyPay1.Caption = 10000 This results in a blank
    lblSummaryWeeklyPay1.Caption = Val(LblPay1.Caption) This also results in a blank

This works ok for me, are you sure the label names are correct?

Also where is LblPay1.Caption getting its value from? If its blank then lblSummaryWeeklyPay1 will be blank.

Can you post your whole code? i.e. Everything under the button click?
0
 
LVL 13

Author Comment

by:gonzal13
ID: 10810351
Please note that the last line of code istxt instead of lbl

   lblSummaryWeeklyPay1.Caption = Val(LblPay1.Caption) This also results in a blank

The above is the complete code for this mnu command

In frustration to see what would happen I forced lblSummaryWeeklyPay1.caption to = 10000

gonzal13(Joe)

Oh, since Microsoft introduced VB.net, the VB6 books can be had at 20 percent of their value on Amazon and half.com
0
 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 10810849
Try this:

lblSummaryWeeklyPay1.Caption = Val(LblPay1.text) This also results in a blank


I know that doesnt make much sense because you have it defined as lblPay1.

But you said "Please note that the last line of code istxt instead of lbl"
I am assuming that you mean its a text box and not a label.


So to get text from a text box you can either do, Text1 or Text1.text.


Good Luck
-Brian
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 19

Accepted Solution

by:
BrianGEFF719 earned 50 total points
ID: 10810850
lblSummaryWeeklyPay1.Caption = Val(LblPay1.text)
0
 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 10810851
lblSummaryWeeklyPay1.Caption = Val(LblPay1.text)
0
 
LVL 13

Author Comment

by:gonzal13
ID: 10815310
Hi:

I shall take your notes to the professor today (Tuesday)

my final version that does not work is
lblSummaryWeeklyPay1.Caption = Val(txtPay1.text)
0
 
LVL 1

Expert Comment

by:MortimerCat
ID: 10817891
lblSummaryWeeklyPay1.Caption = Val(txtPay1.text)

This should work, even if txtPay1.text is blank, the label would come out as zero.

Just a suggestion, have you made the Label forecolor the same as the backcolor? For example printing blue characters on a blue background.  Or have you made the label too small or too big, and the characters are falling of the form?

May I suggest you put some text into the caption properties at design time, just to prove you can see it.


0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem to file 3 74
MS SQL store procedure to calculate and return result 6 56
VB6 ListBox Question 4 42
Advice in Xamarin 21 78
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now