hmm.. with a little research and some craftiness on my part, i've gotten the program to convert celsius to fahrenheit!! here's my code so far.. i think if i keep doing what i'm doing, then i can make all of the formula's work with each selection in the menu. but also, i think i'd like to put like a label at the top of the program that tells the user which temps they're converting to whom. lol so how could i do that? because i could have the label take input from a variable at the end? like "You are currently convertin: var1 to var2"
/*code*/
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Button7 As System.Windows.Forms.Button
Friend WithEvents CtoFinput As System.Windows.Forms.TextBox
Friend WithEvents CtoFtext As System.Windows.Forms.Label
Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem11 As System.Windows.Forms.MenuItem
Friend WithEvents ConvertTemp As System.Windows.Forms.MenuItem
Friend WithEvents CtoF As System.Windows.Forms.MenuItem
Friend WithEvents CtoK As System.Windows.Forms.MenuItem
Friend WithEvents FtoC As System.Windows.Forms.MenuItem
Friend WithEvents FtoK As System.Windows.Forms.MenuItem
Friend WithEvents KtoC As System.Windows.Forms.MenuItem
Friend WithEvents KtoF As System.Windows.Forms.MenuItem
Friend WithEvents Shibby As System.Windows.Forms.MenuItem
Friend WithEvents ShibbyAbout As System.Windows.Forms.MenuItem
Friend WithEvents Close As System.Windows.Forms.MenuItem
Friend WithEvents Result As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.CtoFinput = New System.Windows.Forms.TextBox
Me.Button7 = New System.Windows.Forms.Button
Me.Result = New System.Windows.Forms.TextBox
Me.CtoFtext = New System.Windows.Forms.Label
Me.MainMenu1 = New System.Windows.Forms.MainMenu
Me.MenuItem1 = New System.Windows.Forms.MenuItem
Me.ConvertTemp = New System.Windows.Forms.MenuItem
Me.CtoF = New System.Windows.Forms.MenuItem
Me.CtoK = New System.Windows.Forms.MenuItem
Me.FtoC = New System.Windows.Forms.MenuItem
Me.FtoK = New System.Windows.Forms.MenuItem
Me.KtoC = New System.Windows.Forms.MenuItem
Me.KtoF = New System.Windows.Forms.MenuItem
Me.MenuItem11 = New System.Windows.Forms.MenuItem
Me.Close = New System.Windows.Forms.MenuItem
Me.Shibby = New System.Windows.Forms.MenuItem
Me.ShibbyAbout = New System.Windows.Forms.MenuItem
Me.SuspendLayout()
'
'CtoFinput
'
Me.CtoFinput.Location = New System.Drawing.Point(88, 88)
Me.CtoFinput.Name = "CtoFinput"
Me.CtoFinput.Size = New System.Drawing.Size(120, 20)
Me.CtoFinput.TabIndex = 7
Me.CtoFinput.Text = ""
Me.CtoFinput.Visible = False
'
'Button7
'
Me.Button7.Location = New System.Drawing.Point(16, 200)
Me.Button7.Name = "Button7"
Me.Button7.TabIndex = 9
Me.Button7.Text = "Convert!"
'
'Result
'
Me.Result.Location = New System.Drawing.Point(112, 200)
Me.Result.Name = "Result"
Me.Result.Size = New System.Drawing.Size(168, 20)
Me.Result.TabIndex = 10
Me.Result.Text = ""
'
'CtoFtext
'
Me.CtoFtext.Location = New System.Drawing.Point(80, 64)
Me.CtoFtext.Name = "CtoFtext"
Me.CtoFtext.Size = New System.Drawing.Size(152, 23)
Me.CtoFtext.TabIndex = 11
Me.CtoFtext.Text = "Please input the temperature."
Me.CtoFtext.Visible = False
'
'MainMenu1
'
Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem1, Me.Shibby})
'
'MenuItem1
'
Me.MenuItem1.Index = 0
Me.MenuItem1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.ConvertTemp, Me.MenuItem11, Me.Close})
Me.MenuItem1.Text = "File"
'
'ConvertTemp
'
Me.ConvertTemp.Index = 0
Me.ConvertTemp.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.CtoF, Me.CtoK, Me.FtoC, Me.FtoK, Me.KtoC, Me.KtoF})
Me.ConvertTemp.Text = "Convert Temp"
'
'CtoF
'
Me.CtoF.Index = 0
Me.CtoF.Text = "Celsius to Fahrenheit"
'
'CtoK
'
Me.CtoK.Index = 1
Me.CtoK.Text = "Celsius to Kelvin"
'
'FtoC
'
Me.FtoC.Index = 2
Me.FtoC.Text = "Fahrenheit to Celsius"
'
'FtoK
'
Me.FtoK.Index = 3
Me.FtoK.Text = "Fahrenheit to Kelvin"
'
'KtoC
'
Me.KtoC.Index = 4
Me.KtoC.Text = "Kelvin to Celsius"
'
'KtoF
'
Me.KtoF.Index = 5
Me.KtoF.Text = "Kelvin to Fahrenheit"
'
'MenuItem11
'
Me.MenuItem11.Index = 1
Me.MenuItem11.Text = "----------------"
'
'Close
'
Me.Close.Index = 2
Me.Close.Text = "Exit"
'
'Shibby
'
Me.Shibby.Index = 1
Me.Shibby.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.ShibbyAbout})
Me.Shibby.Text = "Shibby"
'
'ShibbyAbout
'
Me.ShibbyAbout.Index = 0
Me.ShibbyAbout.Text = "About..."
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(344, 266)
Me.Controls.Add(Me.CtoFtext)
Me.Controls.Add(Me.Result)
Me.Controls.Add(Me.Button7)
Me.Controls.Add(Me.CtoFinput)
Me.Menu = Me.MainMenu1
Me.Name = "Form1"
Me.Text = "Temperature Converter - Shibby Inc. © "
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ClassVar.choice = 0
End Sub
Private Sub ShibbyAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShibbyAbout.Click
MessageBox.Show("Shibby Inc. was founded by Tim Hansen and Chris Foreman.", "About Shibby Inc.", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Private Sub Close_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Close.Click
MyBase.Close()
End Sub
Private Sub CtoF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CtoF.Click
ClassVar.choice = 1
CtoFtext.Visible = True
CtoFinput.Visible = True
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Dim formula
Dim c As Integer
c = Val(CtoFinput.Text)
If ClassVar.choice = 1 Then
formula = (9 / 5) * c + 32
Result.Text = Str$(formula)
End If
End Sub
End Class
Public Class ClassVar
Public Shared choice As Integer
End Class