VB學習第四周–字元函數驗證

來源:互聯網
上載者:User

字元函數驗證:

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.