/home/wpollock1/public_html/VB/ConversionDemo.vb

' This program shows various number to string conversions
' Written 2/2010 by Wayne Pollock, Tampa Florida USA

' Option Strict On  ' Turns off automatic conversions
Option Explicit On  ' Requires all variables to be declared

Public Class ConversionDemo
    Private Sub ExitBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitBtn.Click
        Me.Close()
    End Sub

    Private Sub ConvertBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ConvertBtn.Click
        ' Convert the user supplied number in various ways and display the results.
        ' This is the form's Accept Button
        Dim number As Double

        number = Convert.ToDouble(InputNumTxtBox.Text)

        DefaultTxtBox.Text = number
        ToStringTxtBox.Text = number.ToString()
        StrTxtBox.Text = Str(number)
        Convert_ToStringTxtBox.Text = Convert.ToString(number)
        String_FormatTxtBox.Text = String.Format("{0:N}", number)
        ToString_C2_TxtBox.Text = number.ToString("C2")
        ToString_E_TxtBox.Text = number.ToString("E")
        ToString_F2_TxtBox.Text = number.ToString("F2")
    End Sub

    Private Sub InputNumTxtBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InputNumTxtBox.TextChanged
        Dim num As Double
        ConvertBtn.Enabled = Double.TryParse(InputNumTxtBox.Text, num)
    End Sub
End Class