Link to home
Start Free TrialLog in
Avatar of HawaiiDragon
HawaiiDragon

asked on

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

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

Avatar of nepaluz
nepaluz
Flag of United Kingdom of Great Britain and Northern Ireland image

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

Avatar of HawaiiDragon
HawaiiDragon

ASKER

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
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
ASKER CERTIFIED SOLUTION
Avatar of nepaluz
nepaluz
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

Ah. I see you beat me to it.
Well done. Carry on.
thank you very much. I am sure to post more VB in the future!