抢分问题

ccone1111 2005-07-14 10:47:35
vb中有没有这样的函数,就是查找一个字符串中含有某个字符几次的函数,如wesdfwdfw 含有w数2个
...全文
71 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
韧恒 2005-07-14
  • 打赏
  • 举报
回复
方案一:
Private Sub Command1_Click()
Dim s1 As String
Dim s2 As String

s1 = "wesdfwdfw"
s2 = "w"

Debug.Print Len(s1) - Len(Replace(s1, s2, vbNullString))
End Sub

方案二:

Private Sub Command1_Click()
Dim s1 As String
Dim s2 As String

s1 = "wesdfwdfw"
s2 = "w"

Debug.Print UBound(Split(s1, s2))
End Sub
zhzhq800204 2005-07-14
  • 打赏
  • 举报
回复

Private Sub Command1_Click()
Dim s1 As String
Dim s2 As String
Dim Num As Integer
Dim i As Integer
Dim j As Integer
s1 = "wesdfwdfw"
s2 = "w"

Num = 0
i = Len(s1)
For j = 0 To i
If s2 = Mid(s1, j, 1) Then
Num = Num + 1
End If
Next i

End Sub

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧