+ -
当前位置:首页 → 问答吧 → ●一起分享VB源代码◆立即可用于你的工程●你也发布一些经验代码吧

●一起分享VB源代码◆立即可用于你的工程●你也发布一些经验代码吧

时间:2011-09-07

来源:互联网

要求使用“插入源代码,选择VB方式”,代码要求全测试过能用的
相同的功能,有不少设计思路,有的很简单却运行慢,有的很复杂,却运行速度快,有的代码量又少,速度又快
集百家之长,不管咋样,===能立即拿来用才是最实在的,其实运行一下速度快点慢点,对一般人来说基本没影响


我先分享一些

VB code
'┏〓〓〓〓〓〓〓〓〓 FindStrCount,start 〓〓〓〓〓〓〓〓〓┓
'[简介]:
'怎样取得一个字符串在另外一个字符串中出现的次数?
Function FindStrCount(Str1 As String, FindStr As String) As Long
   '帮你写函数,帮你写代码,帮你写模块,帮你设计软件
   '--需要什么函数或功能,可以联系我。
   FindStrCount = UBound(Split(Str1, FindStr))
End Function
'┗〓〓〓〓〓〓〓〓〓  FindStrCount,end  〓〓〓〓〓〓〓〓〓┛

'┏〓〓〓〓〓〓〓〓〓 FindCount,start 〓〓〓〓〓〓〓〓〓┓
'[简介]:
'怎样取得一个字符串在另外一个字符串中出现的次数?
Function FindCount(String1 As String, String2 As String) As Long
   '帮你写函数,帮你写代码,帮你写模块,帮你设计软件
   '--需要什么函数或功能,可以联系我。
         Dim I As Long, iCount As Long
         Dim LenStr As Long
         Dim LenFind As Integer
         LenFind = Len(String2)
         LenStr = Len(String1)
         I = 1
         I = InStr(I, String1, String2, vbTextCompare)
         While I > 0
                iCount = iCount + 1
                I = InStr(I + LenFind, String1, String2, vbTextCompare)
                'Debug.Print iCount & Chr(9) & I
         Wend
   DoEND:
         FindCount = iCount
End Function
'┗〓〓〓〓〓〓〓〓〓  FindCount,end  〓〓〓〓〓〓〓〓〓┛




作者: xiaoyao961   发布时间: 2011-09-07

Function FindStrCount(Str1 As String, FindStr As String) As Long
  '帮你写函数,帮你写代码,帮你写模块,帮你设计软件
  '--需要什么函数或功能,可以联系我。
  FindStrCount = (len(str1)-len(replace(str1,findstr,"")))/len(findstr)
End Function

作者: BestBadGod   发布时间: 2011-09-07

引用 1 楼 bestbadgod 的回复:
Function FindStrCount(Str1 As String, FindStr As String) As Long
'帮你写函数,帮你写代码,帮你写模块,帮你设计软件
'--需要什么函数或功能,可以联系我。
FindStrCount = (len(str1)-len(replace(str1,findstr,"")))/len(findstr)
End Funct……


这个方法也不错,变则通

作者: xiaoyao961   发布时间: 2011-09-07

VB code
Private Function SumHanZi(sFile As String) As Long
    '返回字符串中含有的汉字个数
    Dim s As String, s1 As String, i As Long, j As Long
    s = sFile
    For i = 1 To Len(s)
        s1 = Mid(s, i, 1)
        If Asc(s1) < 0 Then j = j + 1
    Next
    SumHanZi = j
End Function

这样的小函数很多,想要什么功能就写什么

作者: asftrhgjhkjlkttttttt   发布时间: 2011-09-07

作者: li163   发布时间: 2011-09-07

热门下载

更多