嗨我有这个问题找到一个文本框上的字符串 到目前为止,这是我只有它检测到逗号字符,现在ii输入23 pm,24,25am将如何我用这个代码来做这件事,或者任何人都可以给我简单的代码?如何在字符串中找到一个字符串在vb 6.0
Dim tdates() As String
Dim numberOfDates, xcount As Integer
tdates = Split(TXTDAYS.Text, ",")
numberOfDates = UBound(tdates)
Dim counter As Integer
' loop through each input
For counter = 0 To numberOfDates
Dim xdate As String
xdate = LCase$(tdates(counter))
If Len(xdate) <= 2 Then
xcount = xcount + 1
Else
' if the original text has am or pm in it, add .5
If InStr(1, xdate, "am") > 0 Or InStr(1, xdate, "pm") > 0 Then
xcount = xcount + 0.5 'problem here it doesn't count
End If
End If
Next
如果还有更好的方法通过检测逗号和am pm字符串来做到这一点更好。
我修改这个代码我一直在寻找,这是我上来了。 – Denver 2013-03-09 19:20:35
你能解释一下这个函数试图完成什么吗? – 2013-03-09 19:23:23
即时通讯设法检测文本框中的am和pm与整个数字,整数相当于1和上午和下午是0.5,我认为这是错误的代码搜索整数是正确的,但是当我把am或pm的计算结果不正确,就像上面的例子23 pm,24,25pm 23 am = 0.5,24 = 1 and 25 pm = 0.5 – Denver 2013-03-09 19:27:49