Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2011-03-21
7
212 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

861 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