VB小程序,关注我有更多的有趣的VB小程序
1、字符的十进制内码
控件:一个TextBox文本框,一个ListBox列表框,一个CommandButton命令按钮
界面:
代码:
Private Sub Command1_Click()
Dim s As String, ch As String
Dim i As Integer, n As Integer
s = Text1.Text
For i = 1 To Len(s)
ch = Mid(s, i, 1)
n = Asc(ch)
List1.AddItem ch & "内码为:" & Str(n)
Next i
End Sub
2、单词查询
控件:两个TextBox文本框,一个ListBox列表框,一个CommandButton命令按钮
界面:
代码:
Private Sub Command1_Click()
Dim s As String, tmp As String, c As String
Dim n As Integer, i As Integer
Dim flag As Boolean, cnt As Integer
s = Text1.Text
n = Len(s)
flag = False
List1.Clear
For i = 1 To n
c = Mid(s, i, 1)
If c >= "a" And c <= "z" Or c >= "A" And c <= "Z" Then
tmp = tmp + c
If c = Text2.Text Then flag = True: cnt = cnt + 1
Else
If flag Then List1.AddItem tmp
tmp = ""
flag = False
End If
Next i
If cnt = 0 Then
List1.AddItem "找不到合适的单词。"
End If
End Sub
Private Sub Form_Load()
Text1.Text = "请输入英文短句:"
End Sub
想得到更多的VB小程序,请关注我,点击下方的广告可以更好的支持和鼓励我哦!