加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

VB学习第四周--字符函数验证

发布时间:2020-12-17 08:18:08 所属栏目:百科 来源:网络整理
导读:字符函数验证: 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 But

字符函数验证:

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 Sub
End Class

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读