VB如何判断text1中输入同一数值的次数
有VB+EXCEL的小程序,界面及数据库如下图:程序代码如下:
程序代码:
Private Sub Text1_KeyPress(KeyAscii As Integer) Dim rst As New Recordset, sql As String, a As String If KeyAscii = 13 Then a = Trim(Text1) If a = "" Then Exit Sub sql = "select * from [sheet1$] where " & AName & "='" & a & "'" rst.Open sql, con, adOpenDynamic, adLockOptimistic If rst.EOF Then Label2.ForeColor = vbRed Label2.Caption = "错误条码:" & a Text1.Text = "" Else Label2.ForeColor = vbBlack Label2.Caption = "正确条码:" & a sql = "delete from [sheet1$] where " & AName & "='" & a & "'" Text1.Text = "" End If rst.Close KeyAscii = 0 End If
现在需要加一个功能,如果相同的数据输入了两次(前提是输入进去的数据显示“正确条码”)系统能不能提示这个条码已经输入了2次?