Welcome to Dream.In.Code
Become a VB Expert!

Join 137,228 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,892 people online right now. Registration is fast and FREE... Join Now!




Need help with VB coding

 
Closed TopicStart new topic

Need help with VB coding, I'm a little rusty

Phantom_of_the_opera
5 Mar, 2007 - 02:00 PM
Post #1

New D.I.C Head
*

Joined: 13 Nov, 2006
Posts: 43


My Contributions
.

This post has been edited by Phantom_of_the_opera: 3 May, 2007 - 10:33 AM
User is offlineProfile CardPM
+Quote Post

jjuneau
RE: Need Help With VB Coding
6 Mar, 2007 - 02:34 AM
Post #2

New D.I.C Head
*

Joined: 15 Feb, 2007
Posts: 16


My Contributions
Wow dude, I would tackle all those problems one at a time, but to come on a public forum and ask us to do it for you, well, you should know better!
User is offlineProfile CardPM
+Quote Post

matrix_man827
RE: Need Help With VB Coding
6 Mar, 2007 - 07:24 AM
Post #3

New D.I.C Head
*

Joined: 1 Nov, 2006
Posts: 15


My Contributions
I highly doubt that anyone will help you with this due to the fact that there is so much to answer. Reduce your questions some and then come back and someone I am sure will help you.
User is offlineProfile CardPM
+Quote Post

KeyWiz
RE: Need Help With VB Coding
7 Mar, 2007 - 11:25 AM
Post #4

D.I.C Regular
Group Icon

Joined: 26 Oct, 2006
Posts: 428


Dream Kudos: 125
My Contributions
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
User is offlineProfile CardPM
+Quote Post

Closed TopicStart new topic
Time is now: 12/4/08 03:00PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month