473,854 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Almost there...need help displaying result in output Label

16 New Member
I had to create a program that allows the user to input a temp and then click on either the convert to fahrenheit or convert to celsius button and then display that result within the textbox that says "user entered amount in F or C is equal to answer degrees F or C." I have the code written for the convert to Fahrenheit but do not understand how to get the converted temp to display in the text box along with the above desired text. Below is my code for the convert to fahrenheit button...

Expand|Select|Wrap|Line Numbers
  1. Public Class TemperatureConverterForm
  2.    ' converts celsius to fahrenheit
  3.    Private Sub convertFahrenheit_Click(ByVal sender As System.Object, ByVal _
  4.    e As System.EventArgs) Handles convertFahrenheit.Click
  5.       ' declare variables
  6.       Dim degrees As Double
  7.       Dim output As String ' store output
  8.       Dim fahrenheit As Double
  9.  
  10.       ' assign values from user input
  11.       degrees = Val(degreesTextBox.Text)
  12.  
  13.       ' convert to fahrenheit
  14.       fahrenheit = (9 / 5) * degrees + 32
  15.  
  16.       ' set output header
  17.       output = fahrenheit
  18.  
  19.       output = (String.Format("{0:F}", fahrenheit))
  20.  
  21.       outputLabel.Text = output ' display result
  22.  
  23.    End Sub
Anyone that can help me get over this last hurdle of displaying the answer with the proper text with the text box would be greatly greatly appreciated! THanks!
Apr 22 '07 #1
2 11212
SammyB
807 Recognized Expert Contributor
You use an ampersand & to put strings together (it's called concatenation).
Expand|Select|Wrap|Line Numbers
  1.     Private Sub convertFahrenheit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles convertFahrenheit.Click
  2.         ' declare variables
  3.         Dim degrees As Double
  4.         Dim output As String ' output string
  5.         Dim input As String ' input string
  6.         Dim fahrenheit As Double
  7.         ' assign values from user input
  8.         degrees = Val(degreesTextBox.Text)
  9.         ' convert to fahrenheit
  10.         fahrenheit = (9 / 5) * degrees + 32
  11.         ' set strings
  12.         input = (String.Format("{0:F}", degrees))
  13.         output = (String.Format("{0:F}", fahrenheit))
  14.         outputLabel.Text = input & "° C = " & output & "° F" ' display result
  15.     End Sub
Notice that I dropped the line output = fahrenheit: it wasn't doing anything. I also created an input string, just like you did, and, finally, slung them together with ampersands.

But, it seems to me that you are only about 1/3 done. Don't you need to convert from fahrenheit to celsius, also?
Apr 22 '07 #2
lifeshortlivitup
16 New Member
You use an ampersand & to put strings together (it's called concatenation).
Expand|Select|Wrap|Line Numbers
  1.     Private Sub convertFahrenheit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles convertFahrenheit.Click
  2.         ' declare variables
  3.         Dim degrees As Double
  4.         Dim output As String ' output string
  5.         Dim input As String ' input string
  6.         Dim fahrenheit As Double
  7.         ' assign values from user input
  8.         degrees = Val(degreesTextBox.Text)
  9.         ' convert to fahrenheit
  10.         fahrenheit = (9 / 5) * degrees + 32
  11.         ' set strings
  12.         input = (String.Format("{0:F}", degrees))
  13.         output = (String.Format("{0:F}", fahrenheit))
  14.         outputLabel.Text = input & "° C = " & output & "° F" ' display result
  15.     End Sub
Notice that I dropped the line output = fahrenheit: it wasn't doing anything. I also created an input string, just like you did, and, finally, slung them together with ampersands.

But, it seems to me that you are only about 1/3 done. Don't you need to convert from fahrenheit to celsius, also?
Thanks for the input. And yes, I do have to convert from fahrenheit to celsius also but I didn't include that code here because I didn't want to have my entire program on here....Thanks again for the help.
Apr 22 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
11395
by: Todd Shillam | last post by:
Here's my script--need help with output to text file (must be missing something here like closing the file or something). Any help would be greatly appreciated here. Lastly, I'm using Visual Basic .NET 2003. Source... Dim vFileName As String vFileName = Format(Now(), "MM - dd - yyyy") & " - " & vName Dim oFile As System.IO.File Dim oWrite As System.IO.StreamWriter oWrite = oFile.CreateText("C:\" & vFileName & ".txt")
1
1095
by: adMjb | last post by:
I think I am almost there, with help from Johannes Koch (thank you) last week: http://groups.google.co.uk/group/comp.text.xml/browse_thread/thread/b7f55bf554ee288d?hl=en ========================== So now I have this XSL: ========================== <xsl:template match="text"> <p> <xsl:apply-templates/>
1
1360
by: Rob | last post by:
The code below is almost there (it does change the value for EVERY ORDER).... I simply want to be able to change the value of the Delivered Tag to Yes. BUT ONLY if the Order is equal to 123456 ? <?xml version="1.0" encoding="UTF-8" ?> - <AllOrders> - <Order OrderId="123456"> <Route>1</Route> <SalesOrder>123456</SalesOrder>
1
1556
by: swynne | last post by:
Hi friendly people...I am a newb to programming and need a little assistance. I have a small personal ad database created in Access, however all is well until I want the personal ad link to take me to the "details" ASP file. All I want is the Access data to open up in the ASP file. I'm almost there in that I got the link to go to details, but the personal ad info is not there. I'm running XP, Access 2003 and Frontpage 2003. The page is...
2
1248
by: rocky1821 | last post by:
Good day all, Is there another way to output? For example, if I am trying to output something, do I always have to put it in this form? cout<< "output" <<endl; Are there any other ways?
5
2464
by: Harlequin | last post by:
Hi there, I'm something of a newcomer to MS Access so it's more than likely that my question is extremely elementary. I have a form whose record source is a single table in my database. It's purpose is only to display in sequence,every record in this table. Trouble is, one particular field in this table (tblAttendees) is a foreign key in a foreign key - primary key relationship to a field in another table. The foreign key, is of datatype...
0
1346
by: DanWeaver | last post by:
Using asp and SQLserver2005 on shared server and with connection string: <connectionStrings> <remove name="LocalSqlServer"/> <add name="LocalSqlServer" connectionString="Data Source=HYDROGEN;Initial Catalog=dbred;Integrated Security=false;User Id=theuser;Password=blahblah;" providerName="System.Data.SqlClient" /> </connectionStrings>
19
4384
by: RossGK | last post by:
I'm a bit new to javascript - as will be obvious below. I'm using an XMLHttpRequest to get a bit of data from server (django), and it works nicely for single events. But my eventual outcome needs to be a series of data transmissions. I figured requesting data over and over until the data is some value that triggers the stop would be an interesting first attempt. To move forward, I wrapped my initial single data request in a for-loop...
25
7431
by: NDayave | last post by:
How do, I have a form that outputs addresses in a format that can be printed on to 3x7 label paper for envelopes. What I want is a way to enter blank (or " ") rows to the query result where the user specifies so no label is printed in that particular place. I am aware of the problems of inserting blank records to tables. I say this as the other forums I have searched all reply with disbelief and condemnation for inserting blank rows...
0
9899
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9750
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10672
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10740
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10362
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9510
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5738
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5937
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3182
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.