Solved

adding text to an anser in a textbox with a numercial answer in it

Posted on 2011-03-21
7
211 Views
Last Modified: 2012-05-11
Hello again experts I have a new problem

I have 3 textbox fields 1 contains a name the other two have numerical values that I have converted into a percentage to be displayed in a text box.

my problem is this I don't know how to display the text with the answer in the middle of the text box!

tbresult needs to say = 'The' + tbname.text + 'won' + tbresult.Text = FormatNumber(((a / (a + b) * 100)), 3).ToString + of thier games so far this year.

Thanx in advance

Below is my code



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim a, b As Integer

        a = tbwon.Text
        b = tblost.Text
        tbresult.Text = FormatNumber(((a / (a + b) * 100)), 3).ToString



    End Sub

Open in new window

0
Comment
Question by:HawaiiDragon
  • 3
  • 2
  • 2
7 Comments
 
LVL 17

Expert Comment

by:nepaluz
ID: 35186094
change your last line to

tbresult = "The " & tbname.text.tostring & " won " & FormatNumber(((a / (a + b) * 100)), 3).ToString & " of their games so far this year."

Open in new window

0
 

Author Comment

by:HawaiiDragon
ID: 35186125
Error      1      Value of type 'String' cannot be converted to 'System.Windows.Forms.TextBox'.      C:\Documents and Settings\rshier\Local Settings\Application Data\Temporary Projects\Baseball\Form1.vb      9      20      Baseball
0
 

Author Comment

by:HawaiiDragon
ID: 35186145
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim a, b As Integer

        a = tbwon.Text
        b = tblost.Text
    tbresult = "The " & tbname.text.tostring & " won " & FormatNumber(((a / (a + b) * 100)), 3).ToString & " of their games so far this year."

Gennerates the error Value of type 'String' cannot be converted to 'System.Windows.Forms.TextBox'.

Why I wonder.



    End Sub
0
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.

 
LVL 17

Accepted Solution

by:
nepaluz earned 500 total points
ID: 35186149
tbresult.text = "The " & tbname.text.tostring & " won " & FormatNumber(((a / (a + b) * 100)), 3).ToString & " of their games so far this year."

Open in new window


the error is at the begining

tbresult = should be tbresult.text =
0
 
LVL 1

Expert Comment

by:B34RDY
ID: 35186170
Change nepaulz answer to read:
tbresult.Text = "The " & tbname.text.tostring & " won " & FormatNumber(((a / (a + b) * 100)), 3).ToString & " of their games so far this year."

Open in new window

0
 
LVL 1

Expert Comment

by:B34RDY
ID: 35186174
Ah. I see you beat me to it.
Well done. Carry on.
0
 

Author Closing Comment

by:HawaiiDragon
ID: 35206930
thank you very much. I am sure to post more VB in the future!
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Welcome back!  My apologies for taking so long to write part two of this series; it's been a long time coming!  As I promised in Part 1, this article will focus on how to locate those elusive AD properties that you are searching for.  Why is this us…
Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 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