1.编写程序VB,在一个文本框中输入一个简单的英文句子,找出这个英
Private Sub Command1_Click()If Text1.Text = "" Then Exit SubDim word As Variant,s As StringDim k As Integer,maxw As String,n As Integers = Replace(Replace(Text1.Text,","," "),"."," ")s = Replace(Replace(s,","," "),"."," ")s = Replace(s,vbCrLf," ")s = Trim(Replace(s," "," "))If s = "" Then Exit Subword = Split(s," ")n = UBound(word)For k = 0 To nIf n = k Then Exit ForIf Len(CStr(word(k + 1))) > Len(maxw) Thenmaxw = word(k + 1)End IfNextMsgBox maxw & "=" & Len(maxw) & "字节"End Sub。
2.【编写程序,在一个文本框中输入一个简单的英文句子,找出这个英文
可是如下代码要加入盘符才行 如何不用输入盘符能输入文件名,就能实现搜索功能 多谢了 我的代码如下:procedure search(dir:string); var targetpath:string; sr:tsearchrec; begin targetpath:=extractfilepath(dir); if findfirst(dir,faanyfile,sr)=0 then repeat if((sr.Name '.')and(sr.Name '..')) and((filegetattr(targetpath+sr.Name)and fadirectory) fadirectory) then form1.Memo1.Lines.Add(targetpath+sr.Name); until findnext(sr) 0; if findfirst(dir,faanyfile,sr)=0 then repeat if ((sr.Name '.')and(sr.Name '..')) and((filegetattr(targetpath+sr.Name)and fadirectory)=fadirectory) then search(targetpath+sr.Name+ '\*.* '); until findnext(sr) 0; end; procedure TForm1.Button1Click(Sender:TObject); begin memo1.Clear; search(edit1.Text); messagedlg( '文件搜索完毕 ',mtinformation,[mbok],0); end; procedure TForm1.FormCreate(Sender:TObject); begin edit1.Text:= 'c:\ '; end;。
3.英文打字练习的vb程序
'要有两个标签一个按钮和两个时间控件
Dim s As Integer
Private Sub Command1_Click()
If Command1.Caption = "开始" Then
s = 0
Command1.Enabled = False
Timer1.Interval = 60000
Timer2.Interval = 10
Label1.Caption = "分数" & s
Timer1.Enabled = True
Timer2.Enabled = True
Label2.Caption = Chr(Int(Rnd() * 26) + 65)
Label2.Top = 0
Label2.Left = Int(Rnd() * (Me.Width - Label2.Width))
End If
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If Chr(KeyCode) = Label2.Caption Then
Label2.Caption = Chr(Int(Rnd() * 26) + 65)
Label2.Top = 0
Label2.Left = Int(Rnd() * (Me.Width - Label2.Width))
s = s + 10
Label1.Caption = "分数" & s
End If
End Sub
Private Sub Form_Load()
Command1.Caption = "开始"
Label1.Caption = ""
Label2.Caption = ""
End Sub
Private Sub Timer1_Timer()
Timer1.Interval = 0
Timer2.Interval = 0
Timer1.Enabled = False
Timer2.Enabled = False
Command1.Enabled = True
Label1.Caption = "游戏结束!总分:" & s
End Sub
Private Sub Timer2_Timer()
Label2.Top = Label2.Top + 40
If Label2.Top > Me.Height Then
Label2.Caption = Chr(Int(Rnd() * 26) + 65)
Label2.Top = 0
Label2.Left = Int(Rnd() * (Me.Width - Label2.Width))
End If
End Sub
4.编写VB程序,在文本框中输入一个简单的英文句子,找出这个句子中
'不用这么复杂,你的代码太长没有看,如果一定用你的代码,我再给你修改一下 Option Explicit Private Sub Command1_Click() Dim i As Long, arr, n As Long If InStr(Text1, " ") > 0 Then arr = Split(Text1) For i = 0 To UBound(arr) If Trim(arr(i)) <> "" Then If Len(Trim(arr(i))) > n Then n = i End If Next MsgBox "最长单词:" & arr(n) End If End Sub。
5.请教一段简短的VB程序代码翻译
For i = 5 To 10 '从第五个开始每次取一个字
a = Mid(Text1.Text, i, 1) '取第i个字
For j = 1 To 10
If a = zf(j) Then '如果a= zf(j) 返回的那么
Sum = Sum + dm(j) * 2 ^ (i - 1) 'sum=自身加上dm(j) 乘以 2的(i - 1) 次方
Exit For '退出j循环
Else
If j = 10 Then '如果循环完毕还没找到,那么非法
MsgBox ("非法字符5-10!重新输入!") ' 提示信息
Exit Sub ' 退出过程
End If
End If
Next
Next
6.用VB编写一个程序,输入一个英文句子,可以统计出各个元音字母以
我比较喜欢用正则表达式,VB6.0还是第一次用,好久没写VB代码了 '//首先要引用Microsoft VBScript Regular Express 5.5Private Sub Command1_Click() If Trim(Text1.Text) <> "" Then Dim str As String '//处理一下空格 str = Replace(Trim(Text1.Text), " ", "") Dim lenstr As Integer lenstr = Len(str) Dim nvchar As String Dim en_count, envowel_count, encons_count, orther_count As Integer For i = 1 To lenstr Step 1 nvchar = Mid(str, i, 1) If IsEn(nvchar) = True Then en_count = en_count + 1 If IsEnvowel(nvchar) = True Then envowel_count = envowel_count + 1 Else encons_count = encons_count + 1 End If Else orther_count = orther_count + 1 End If Next i MsgBox "一共有字母" + CStr(en_count) + "个,其他字符" + CStr(orther_count) + "个。
其中辅音" + CStr(encons_count) + "个,元音" + CStr(envowel_count) + "个" Else MsgBox "文本输入是空值!" End IfEnd Sub'//判断是否英文字母Function IsEn(varchar As String) As Boolean Dim rex As RegExp Set rex = New RegExp rex.Pattern = "[a-zA-Z]" IsEn = rex.Test(varchar)End Function'//判断是否元音字母Function IsEnvowel(varchar As String) As Boolean Dim rex As RegExp Set rex = New RegExp rex.Pattern = "[aeiouAEIOU]" IsEnvowel = rex.Test(varchar)End Function。
7.请教一段简短的VB程序代码翻译
For i = 5 To 10 '从第五个开始每次取一个字 a = Mid(Text1.Text, i, 1) '取第i个字 For j = 1 To 10 If a = zf(j) Then '如果a= zf(j) 返回的那么 Sum = Sum + dm(j) * 2 ^ (i - 1) 'sum=自身加上dm(j) 乘以 2的(i - 1) 次方 Exit For '退出j循环 Else If j = 10 Then '如果循环完毕还没找到,那么非法 MsgBox ("非法字符5-10!重新输入!") ' 提示信息 Exit Sub ' 退出过程 End If End If NextNext。
转载请注明出处短句子网 » 英语短句翻转vb程序