|
-
Aug 6th, 2004, 02:58 PM
#1
Thread Starter
Member
textboxes (NEWBIE question)
OK, I am an ANSI-C type programmer trying to create a simmple VB.net App. I have several text boxes where the user enters certain numbers. I need to take those entries and produce a result in another text box. To test how to do this, I have a simple equation in code and am trying to place the result in a textbox, with no success. I would appreciate any steering in the right direction.
Richard
-
Aug 6th, 2004, 03:15 PM
#2
Frenzied Member
Not sure how much you know about vb, but if your text box is named, say myTextBox, you set the text property - e.g. myTextBox.Text = "Hello".
If you're adding numbers, you may need to do some error checking to make sure the user did not type in letters.
Can you post some code to point out where you're having troubles? Any exceptions being raised?
Mike
-
Aug 6th, 2004, 04:19 PM
#3
Thread Starter
Member
Basically I need to take the numbers from the other text boxes and, after calculating an equation, put the result in another text box. So myTextBox.Text = "Hello" becomes myTextBox.Text = Result where Result is the equation answer. Of course I have tried this and it does not work. The result does not have to be in a text box, perhaps that is my problem.
Richard
-
Aug 6th, 2004, 04:25 PM
#4
Frenzied Member
Post some code, so we can see why it doesn't work. Probably something simple, but one can guess forever.
-
Aug 6th, 2004, 05:27 PM
#5
Thread Starter
Member
Mike,
I got it to work. I appreciate the help. I think I need to learn (suffer) more before I waste people time on this forum. I will be back when I have a more interesting problem. Way too early to display my code!
One question I still have, although I have the text box outputing the answer, it seems like the text box is an input point. What is a better way to display the answer? e.g as plain text in/on the form.
Richard
-
Aug 6th, 2004, 05:33 PM
#6
Frenzied Member
I guess that would be a Label control. It also has a Text property. Sometimes can be useful to set the AutoSize property to true also, so it auto-expands to fit your text.
-
Aug 7th, 2004, 07:13 AM
#7
PowerPoster
Hi,
You could also use a messagebox.show to display the result in a manner which demands attention.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Aug 7th, 2004, 09:40 AM
#8
Thread Starter
Member
Output as Plain Text?
OK I have had some sucess with code like:
Fcco.Text = Val(Fosc.Text) * Val(M.Text) * Val(P.Text) * 2
This places the result in the Fcco textbox. Since Fcco IS a textbox, the user could plug values in there which is not what I want since it is only an output. Anyway to have the result show up as plain text?
Richard
-
Aug 7th, 2004, 10:08 AM
#9
Thread Starter
Member
OK, I have some plain text output using label:
test1.Text = Str$(A)
Richard
-
Aug 7th, 2004, 02:12 PM
#10
PowerPoster
Re: Output as Plain Text?
Originally posted by richas
OK I have had some sucess with code like:
Fcco.Text = Val(Fosc.Text) * Val(M.Text) * Val(P.Text) * 2
This places the result in the Fcco textbox. Since Fcco IS a textbox, the user could plug values in there which is not what I want since it is only an output. Anyway to have the result show up as plain text?
Richard
In VB6 textboxes were of the variant type. In VB.NET they are solely strings. Therefore
VB Code:
Fcco.Text = Cstr(Val(Fosc.Text) * Val(M.Text) * Val(P.Text) * 2)
There are other ways to convert to strings but that is the easiest.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Aug 9th, 2004, 01:25 AM
#11
This is all very good and nice but I'd also suggest that you use a naming convention for your variables and controls. For example, naming a textbox as "M" won't be very helpful later on when you're asking someone else for help, or when you come back to your code later on.
I'd name a textbox as txtM instead, integers as intSomething and strings as strFrog.
HTH
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
|