4个回答
展开全部
Private Sub Command1_Click() '如果文章贴在Text2中
Dim danci As String '单词
Dim wenzhang As String '文章
Dim temp As String
Dim cishu As Integer '出现次数
danci = LCase(Text1)
If Trim(danci) = "" Then Exit Sub
wenzhang = LCase(Text2)
temp = Replace(wenzhang, danci, "")
cishu = (Len(wenzhang) - Len(temp)) / Len(danci)
MsgBox "单词" & danci & "出现次数为:" & cishu
End Sub
Private Sub Command2_Click() '如果文章从文件中读取
Dim danci As String '单词
Dim wenzhang As String '文章
Dim temp As String
Dim cishu As Integer '出现次数
danci = LCase(Text1)
If Trim(danci) = "" Then Exit Sub
Open "带完整路径的文件名称,如:d:\abc\efg.txt" For Input As #1
wenzhang = LCase(StrConv(InputB$(LOF(1), #1), vbUnicode))
Close #1
temp = Replace(wenzhang, danci, "")
cishu = (Len(wenzhang) - Len(temp)) / Len(danci)
MsgBox "单词" & danci & "出现次数为:" & cishu
End Sub
Dim danci As String '单词
Dim wenzhang As String '文章
Dim temp As String
Dim cishu As Integer '出现次数
danci = LCase(Text1)
If Trim(danci) = "" Then Exit Sub
wenzhang = LCase(Text2)
temp = Replace(wenzhang, danci, "")
cishu = (Len(wenzhang) - Len(temp)) / Len(danci)
MsgBox "单词" & danci & "出现次数为:" & cishu
End Sub
Private Sub Command2_Click() '如果文章从文件中读取
Dim danci As String '单词
Dim wenzhang As String '文章
Dim temp As String
Dim cishu As Integer '出现次数
danci = LCase(Text1)
If Trim(danci) = "" Then Exit Sub
Open "带完整路径的文件名称,如:d:\abc\efg.txt" For Input As #1
wenzhang = LCase(StrConv(InputB$(LOF(1), #1), vbUnicode))
Close #1
temp = Replace(wenzhang, danci, "")
cishu = (Len(wenzhang) - Len(temp)) / Len(danci)
MsgBox "单词" & danci & "出现次数为:" & cishu
End Sub
展开全部
我有一个简单的方法:
假设单词在text1.text
文章在text2.text
查找按钮为command1
Option Explicit
Option Base 1
Private Sub Command1_Click()
Dim tmp As String, seg() As String, count As Long
tmp = Replace(Text2.Text, Text1.Text, vbNullChar)
seg = Split(tmp, vbNullChar)
count = UBound(seg)
MsgBox count
End Sub
假设单词在text1.text
文章在text2.text
查找按钮为command1
Option Explicit
Option Base 1
Private Sub Command1_Click()
Dim tmp As String, seg() As String, count As Long
tmp = Replace(Text2.Text, Text1.Text, vbNullChar)
seg = Split(tmp, vbNullChar)
count = UBound(seg)
MsgBox count
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
function GetWordCount(Find as string) as long
dim sFile as string
dim lngFile as long
lngFile=freefile
open "d:\myFile.txt" for binary as lngFile
sFile=space(lof(lngFile))
get lngFile,,sFile
close
GetWordCount=ubound(split(lcase(sFile),lcase(Find)))
end function
private cub command1_click()
msgbox GetWordCount(trim(text1))
end sub
dim sFile as string
dim lngFile as long
lngFile=freefile
open "d:\myFile.txt" for binary as lngFile
sFile=space(lof(lngFile))
get lngFile,,sFile
close
GetWordCount=ubound(split(lcase(sFile),lcase(Find)))
end function
private cub command1_click()
msgbox GetWordCount(trim(text1))
end sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
for循环
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询