Solved

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

Posted on 2011-03-21
7
214 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
[X]
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
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

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.

Question has a verified solution.

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

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
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…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

691 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