标题: 求助数据处理问题 [打印本页] 作者: forman 时间: 2008-12-9 12:34 标题: 求助数据处理问题 比如我 在窗体的 A控件上输入 01020305060507 如何判断 每两个字符都不会重复!(01,02,03,05,06,05,07 )比如这个有两个05就弹出提示·字符位数是不确定的·有时多有时少·作者: Henry D. Sy 时间: 2008-12-9 12:46
用循环取出两位数,然后循环对比。作者: forman 时间: 2008-12-9 13:08
Private Sub asdfas_AfterUpdate()
Dim use(10) As String, i As Integer, k As String
k = asdfas.Text
For i = 1 To 10
use(i) = Mid(k, 2 * i - 1, 2)
Next i
End Sub
之后就不会怎么写了·麻烦帮我补下··作者: Henry D. Sy 时间: 2008-12-9 13:39
原帖由 forman 于 2008-12-9 13:08 发表
之后就不会怎么写了·麻烦 ...
没有测试,你自己测试一下
Private Sub Text0_AfterUpdate()
Dim intCount As Integer, H As Integer
Dim I As Integer, J As Integer, K As Integer
Dim strArray() As String
If IsNull(Me.Text0) Then
MsgBox "请输入数据"
Exit Sub
Else
intCount = Len(Me.Text0)
If intCount Mod 2 <> 0 Then
MsgBox "请输入偶数位的数据"
Exit Sub
End If
End If
H = intCount / 2 - 1
ReDim strArray(H)
For I = 0 To intCount - 2 Step 2
strArray(J) = Mid(Me.Text0, I + 1, 2)
J = J + 1
Next
K = UBound(strArray)
For I = 0 To K
For J = 0 To K
If I <> J Then
If strArray(I) = strArray(J) Then
MsgBox strArray(I) & " 有重复"
Exit Sub
End If
End If
Next
Next
End Sub
复制代码
作者: forman 时间: 2008-12-9 14:12
Private Sub asdfas_AfterUpdate()
Dim intCount As Integer, H As Integer
Dim I As Integer, J As Integer, K As Integer
Dim strArray() As String
If intCount = Len(Me.asdfas) Then
If intCount Mod 2 <> 0 Then
MsgBox "请输入偶数位的数据"
End If
End If
H = intCount / 2 - 1
ReDim strArray(H)
For I = 0 To intCount - 2 Step 2
strArray(J) = Mid(Me.asdfas, I + 1, 2)
J = J + 1
Next
K = UBound(strArray)
For I = 0 To K
For J = 0 To K
If I <> J Then
If strArray(I) = strArray(J) Then
MsgBox strArray(I) & " 有重复"
Exit Sub
End If
End If
Next
Next
End Sub
我改成这样,出现错误“运行错误9,下标越界”···ReDim strArray(H)这句变黄了
[ 本帖最后由 forman 于 2008-12-9 14:13 编辑 ]作者: Henry D. Sy 时间: 2008-12-9 14:22
If intCount = Len(Me.asdfas) Then
If intCount Mod 2 <> 0 Then
MsgBox "请输入偶数位的数据"
End If
End If
Private Sub asdfas_AfterUpdate()
Dim intCount As Integer, H As Integer
Dim I As Integer, J As Integer, K As Integer
Dim strArray() As String
If intCount = Len(Me.asdfas.Text) Then
If intCount Mod 2 <> 0 Then
MsgBox "请输入偶数位的数据"
End If
End If
H = intCount / 2 - 1
ReDim strArray(H)
For I = 0 To intCount - 2 Step 2
strArray(J) = Mid(Me.asdfas.Text, I + 1, 2)
J = J + 1
Next
K = UBound(strArray)
For I = 0 To K
For J = 0 To K
If I <> J Then
If strArray(I) = strArray(J) Then
MsgBox strArray(I) & " 有重复"
Exit Sub
End If
End If
Next
Next
End Sub
是不是应该这样?
[ 本帖最后由 forman 于 2008-12-9 14:28 编辑 ]作者: Henry D. Sy 时间: 2008-12-9 14:29