QUOTE(Phantom_of_the_opera @ 5 Mar, 2007 - 03:00 PM)

Ok well here are the requirements for the project:
* Using VB2005, Create a program that converts temperatures
* Button to convert F to C (btn...)
* Button to convert C to F (btn...)
* Conversion buttons should be DISABLED until user enters temperature
* Use TextBox to Input temperature (txt...) , MaxLength = 3
* See TextChanged Event
* Output result in label (lbl...) as follows:
* 32 degrees F converts to 0 degrees C
* 100 degrees C converts to 212 degrees F
* -40 degrees C converts to -40 degres F
* Include a related picture in a PictureBox (pic...)
* Include an Exit Button (btn...)
* Include a Clear button that will clear the textbox and the label and will disable the conversion buttons again
* Make form (frm...) have the title bar = YOUR LAST NAME
* Comment (name, date, purpose)
* Use good object & variable naming
* Hand in via WebDrive
* EXTRA:
* .. Use 'IsNumeric( )' to convert only if the input is numeric
* .. or Use 'Convert.ToInt32( )' to convert only if the input is numeric
* .. or Use MaskedTextBox to restrict the input to 3 digit input
and here is my coding that I have so far for the program I just can't figure out how to make it work. It keeps giving me my error message saying that they entered the wrong thing, and to enter a number between 0 - 999. also I don't know how to display the data in the label once it has been calculated either anyways, here is my code:
CODE
Public Class frmClarey
Dim Celsius As Integer
Dim Fahrenheit As Integer
Dim input As Long
Private Sub btnFtoc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFtoc.Click
'txtTemp.Text = input
Celsius = (5 / 9) * (input - 32)
picCelsius.Visible = True
picFahrenheit.Visible = False
End Sub
Private Sub btnCtof_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCtof.Click
'txtTemp.Text = input
Fahrenheit = (9 / 5) * input + 32
picCelsius.Visible = False
picFahrenheit.Visible = True
End Sub
Private Sub txtTemp_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtTemp.TextChanged
If IsNumeric(input) Then
txtTemp.Text = input
Else
MessageBox.Show("ERROR! The input must be an integer between 0-999. Please re-enter the number.")
End If
Me.btnClear.Enabled = True
Me.btnFtoc.Enabled = True
Me.btnCtof.Enabled = True
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
Me.txtTemp.Clear()
Me.btnFtoc.Enabled = False
Me.btnCtof.Enabled = False
Me.picCelsius.Visible = False
Me.picFahrenheit.Visible = False
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Close()
End Sub
Private Sub lblResult_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblResult.Click
' If = Then
'lblResult.Text = Celsius
' Else if btnCtof = then
'lblResult.Text = Fahrenheit
'End If
End Sub
End Class
Thanks in advance,
Shayne
1. You are using the varriable (input) but I don't see a reference to it otherwise.
2. Your changing label info seems to occur only if you click on the label.
I think you are trying to go about this the wrong way.
Create your form to contain all the objects, and make it look functional.
Then Check for changes in the textbox, but only turn the buttons on from that info.
Then once a button is enabled, click it, and do ALL the work there.
Check for the Textbox.TEXT and make sure it is a numerical value, if not then activate the message box
With a Numerical Value in Textbox.TEXT first CONVERT it to a Long or Double
Then calculate the new temperature
then output LblDisplay.Caption = CSTR(NewTempature)
or if using VB.Net lblDisplay.Text = CSTR(NewTempature)
as for not getting help, New Members should not tell other new members what to expect from something they know nothing about.
As long as you post your code and show your effort you will get help.
We may not address every little detail, but we will help you learn and UNDERSTAND what you are doing.
This post has been edited by KeyWiz: 7 Mar, 2007 - 11:28 AM