●字串與整數的轉換處理:
●字串與浮點數的轉換處理:
●整數與浮點數的轉換處理:
●字串合併:
●字串運算:只要是使用 & 運算子做資料連接,最後得到的是字串
●利用 CType 轉換指定的型別:
Public Class Form1
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
Dim a1 As Integer = 100
Dim b1 As String = "199"
TextBox1.Text = a1 & " 整數"
TextBox2.Text = b1 & " 字串"
TextBox3.Text = CStr(a1) & " Integer --> String"
TextBox4.Text = CInt(b1) & " String --> Integer"
End Sub
Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click
Dim a1 As Single = 101.11
Dim b1 As String = "202.22"
TextBox1.Text = a1 & " 單精數"
TextBox2.Text = b1 & " 字串"
TextBox3.Text = CStr(a1) & " Single --> String"
TextBox4.Text = CSng(b1) & " String --> Single"
End Sub
Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click
Dim a1 As Integer = 100
Dim b1 As Single = 199.99
TextBox1.Text = a1 & " 整數"
TextBox2.Text = b1 & " 單精數"
TextBox3.Text = CSng(a1) & " Integer --> Single"
TextBox4.Text = CInt(b1) & " Single --> Integer"
End Sub
Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
Dim a1 As String = "Hello Every one "
Dim b1 As String = "哈囉 大家好 "
TextBox1.Text = a1 & " 字串"
TextBox2.Text = b1 & " 字串"
TextBox3.Text = a1 & b1 & " String相加 "
TextBox4.Text = b1 & a1 & " String相加 "
End Sub
Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click
Dim a1 As String = "12"
Dim b1 As String = "34"
TextBox1.Text = a1 & " 字串"
TextBox2.Text = b1 & " 字串"
TextBox3.Text = CSng(a1 & b1) & " String相加轉單精數 "
TextBox4.Text = (CSng(b1 & a1) + CSng(a1 & b1)) & "單精數相加 "
End Sub
Private Sub Label6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label6.Click
Dim a1 As String = "100"
Dim b1 As Integer = 199
Dim c1 As Double = 299.9999
Dim a21, a22 As String
Dim b21, b22 As Integer
Dim c21, c22 As Double
a21 = CType(b1, String)
a22 = CType(c1, String)
b21 = CType(a1, Integer)
b22 = CType(c1, Integer)
c21 = CType(a1, Double)
c22 = CType(b1, Double)
TextBox1.Text = a1 & " 字串"
TextBox2.Text = b1 & " 整數"
TextBox5.Text = c1 & " 倍精數"
TextBox3.Text = a21 & " " & a22 & " 轉字串 "
TextBox4.Text = b21 & " " & b22 & " 轉整數 "
TextBox6.Text = c21 & " " & c22 & " 轉倍精數 "
End Sub
End Class
沒有留言:
張貼留言