字元函數驗證:
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click TextBox2.Text = Len(TextBox1.Text) Label2.Text = Button1.Text & "函數的結果" End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click TextBox2.Text = Trim(TextBox1.Text) Label2.Text = Button4.Text & "函數的結果" End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click Dim a% a = InputBox("請輸入重複出現的次數(必須為數字)", "StrDup函數") TextBox2.Text = StrDup(a, TextBox1.Text) Label2.Text = Button5.Text & "函數的結果" End Sub Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click Dim b$ b = InputBox("輸入尋找字串", "InStr函數") TextBox2.Text = InStr(TextBox1.Text, b) Label2.Text = Button6.Text & "函數的結果" End Sub Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click Dim c$, d$ c = InputBox("輸入需要替換的字串", "Replace函數") d = InputBox("輸入替換後的字串", "Replace函數") TextBox2.Text = Replace(TextBox1.Text, c, d) Label2.Text = Button7.Text & "函數的結果" End Sub Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click Dim m%, n% m = InputBox("輸入從左開始取得位置(必須為數字)", "Mid函數") n = InputBox("輸入要取得字元數(必須為數字)", "Mid函數") TextBox2.Text = Mid(TextBox1.Text, m, n) Label2.Text = Button8.Text & "函數的結果" End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End SubEnd Class