Convert input value in a TextField : TextBox « GUI « VB.Net Tutorial

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » GUI » TextBox 
14.23.2.Convert input value in a TextField
Convert input value in a TextField
Imports System.Windows.Forms

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class ConvertForm
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing AndAlso components IsNot Nothing Then
            components.Dispose()
        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.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.SourceFahrenheit = New System.Windows.Forms.RadioButton
        Me.SourceCelsius = New System.Windows.Forms.RadioButton
        Me.SourceKelvin = New System.Windows.Forms.RadioButton
        Me.ValueFahrenheit = New System.Windows.Forms.TextBox
        Me.ValueCelsius = New System.Windows.Forms.TextBox
        Me.ValueKelvin = New System.Windows.Forms.TextBox
        Me.ConvertTemperature = New System.Windows.Forms.Button
        Me.SuspendLayout()
        '
        'SourceFahrenheit
        '
        Me.SourceFahrenheit.AutoSize = True
        Me.SourceFahrenheit.Checked = True
        Me.SourceFahrenheit.Location = New System.Drawing.Point(1624)
        Me.SourceFahrenheit.Name = "SourceFahrenheit"
        Me.SourceFahrenheit.Size = New System.Drawing.Size(7517)
        Me.SourceFahrenheit.TabIndex = 0
        Me.SourceFahrenheit.TabStop = True
        Me.SourceFahrenheit.Text = "&Fahrenheit"
        Me.SourceFahrenheit.UseVisualStyleBackColor = True
        '
        'SourceCelsius
        '
        Me.SourceCelsius.AutoSize = True
        Me.SourceCelsius.Location = New System.Drawing.Point(1656)
        Me.SourceCelsius.Name = "SourceCelsius"
        Me.SourceCelsius.Size = New System.Drawing.Size(5817)
        Me.SourceCelsius.TabIndex = 2
        Me.SourceCelsius.Text = "&Celsius"
        Me.SourceCelsius.UseVisualStyleBackColor = True
        '
        'SourceKelvin
        '
        Me.SourceKelvin.AutoSize = True
        Me.SourceKelvin.Location = New System.Drawing.Point(1688)
        Me.SourceKelvin.Name = "SourceKelvin"
        Me.SourceKelvin.Size = New System.Drawing.Size(5317)
        Me.SourceKelvin.TabIndex = 4
        Me.SourceKelvin.Text = "&kelvin"
        Me.SourceKelvin.UseVisualStyleBackColor = True
        '
        'ValueFahrenheit
        '
        Me.ValueFahrenheit.Location = New System.Drawing.Point(12024)
        Me.ValueFahrenheit.Name = "ValueFahrenheit"
        Me.ValueFahrenheit.Size = New System.Drawing.Size(10020)
        Me.ValueFahrenheit.TabIndex = 1
        '
        'ValueCelsius
        '
        Me.ValueCelsius.Location = New System.Drawing.Point(12056)
        Me.ValueCelsius.Name = "ValueCelsius"
        Me.ValueCelsius.Size = New System.Drawing.Size(10020)
        Me.ValueCelsius.TabIndex = 3
        '
        'ValueKelvin
        '
        Me.ValueKelvin.Location = New System.Drawing.Point(12088)
        Me.ValueKelvin.Name = "ValueKelvin"
        Me.ValueKelvin.Size = New System.Drawing.Size(10020)
        Me.ValueKelvin.TabIndex = 5
        '
        'ConvertTemperature
        '
        Me.ConvertTemperature.Location = New System.Drawing.Point(144128)
        Me.ConvertTemperature.Name = "ConvertTemperature"
        Me.ConvertTemperature.Size = New System.Drawing.Size(7523)
        Me.ConvertTemperature.TabIndex = 6
        Me.ConvertTemperature.Text = "Convert"
        Me.ConvertTemperature.UseVisualStyleBackColor = True
        '
        'ConvertForm
        '
        Me.AcceptButton = Me.ConvertTemperature
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(245169)
        Me.Controls.Add(Me.ConvertTemperature)
        Me.Controls.Add(Me.ValueKelvin)
        Me.Controls.Add(Me.ValueCelsius)
        Me.Controls.Add(Me.ValueFahrenheit)
        Me.Controls.Add(Me.SourceKelvin)
        Me.Controls.Add(Me.SourceCelsius)
        Me.Controls.Add(Me.SourceFahrenheit)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "ConvertForm"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Convert Temperatures"
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub
    Friend WithEvents SourceFahrenheit As System.Windows.Forms.RadioButton
    Friend WithEvents SourceCelsius As System.Windows.Forms.RadioButton
    Friend WithEvents SourceKelvin As System.Windows.Forms.RadioButton
    Friend WithEvents ValueFahrenheit As System.Windows.Forms.TextBox
    Friend WithEvents ValueCelsius As System.Windows.Forms.TextBox
    Friend WithEvents ValueKelvin As System.Windows.Forms.TextBox
    Friend WithEvents ConvertTemperature As System.Windows.Forms.Button

End Class
Public Class ConvertForm
    Private Sub ConvertTemperature_Click(ByVal sender As System.Object, ByVal e As System.EventArgsHandles ConvertTemperature.Click
        On Error Resume Next

        If (SourceFahrenheit.Checked = TrueThen
            If (IsNumeric(ValueFahrenheit.Text= TrueThen
                ValueCelsius.Text = _
                   (Val(ValueFahrenheit.Text321.8
                ValueKelvin.Text = _
                   ((Val(ValueFahrenheit.Text321.8273.15
            Else
                ValueCelsius.Text = "Error"
                ValueKelvin.Text = "Error"
            End If
        ElseIf (SourceCelsius.Checked = TrueThen
            If (IsNumeric(ValueCelsius.Text= TrueThen
                ValueFahrenheit.Text = _
                   (Val(ValueCelsius.Text1.832
                ValueKelvin.Text = Val(ValueCelsius.Text273.15
            Else
                ValueFahrenheit.Text = "Error"
                ValueKelvin.Text = "Error"
            End If
        Else
            If (IsNumeric(ValueKelvin.Text= TrueThen
                ValueFahrenheit.Text = _
                   ((Val(ValueKelvin.Text273.151.832
                ValueCelsius.Text = Val(ValueKelvin.Text273.15
            Else
                ValueFahrenheit.Text = "Error"
                ValueCelsius.Text = "Error"
            End If
        End If
    End Sub
End Class


public class FahrenheitCelsiusConverter
    Public Shared Sub Main()
        Application.Run(New ConvertForm)
    End Sub
End Class
14.23.TextBox
14.23.1.Get input from TextBox and Set to LabelGet input from TextBox and Set to Label
14.23.2.Convert input value in a TextFieldConvert input value in a TextField
14.23.3.Inherit TextBox to create custom control based on TextBox
14.23.4.Display text file in a TextBoxDisplay text file in a TextBox
14.23.5.Numeric TextBoxNumeric TextBox
14.23.6.TextBox Text Changed EventTextBox Text Changed Event
14.23.7.Comprehensive Demo for TextBoxComprehensive Demo for TextBox
14.23.8.Change TextBox font by RadioButton and CheckBoxChange TextBox font by RadioButton and CheckBox
14.23.9.Get selected text in TextBoxGet selected text in TextBox
14.23.10.Create PasswordField by setting the TextBox.PasswordCharCreate PasswordField by setting the TextBox.PasswordChar
14.23.11.Copy selection text from a TextBox and paste to anotherCopy selection text from a TextBox and paste to another
14.23.12.Multiline Text BoxesMultiline Text Boxes
14.23.13.Disable TextBox Context MenuDisable TextBox Context Menu
14.23.14.Save text in TextBox to a file
14.23.15.Handles the Click event of a Button to change the background color of a TextBox.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.