Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to do string comparison using vb6?

Status
Not open for further replies.

BlueByte

Programmer
Jul 18, 2003
28
IN
hi all!
i have a table 'TAB' as under:

ID Name Joint1 Joint2 Joint3 Joint4
=============================================
01 A P Q R S

i have a form that inputs these values into this table.

issue: whenever a new entry with the same name ('A')
is about to be inserted into this table, i need to check if
the sequence of joint names 1 thro 4 is same as above.
that means the code should allow all other 23 combinations
possible except for the already inserted combination of P,Q,R,S.

how to implement this using string comparison?


thnx,
blubyte
 
Option Explicit
Option Compare Text
'If you want to compare text if it's a binary
'option compare binary

Private Sub one()
It_Bool = Comp_String(Array("P", "Q", "R", "S"))
End Sub

Private Function Comp_String(str_new) As Boolean
'I don't know your table format
'so here you must make a conexion
For i = 1 To Table.RecordCount
If table.joint1.Value = str_new(1) and ..... then
Comp_String = False
Exit Function
Next i
Comp_String = True
End Function
 
Option Explicit
Option Compare Text
Private Sub one()
It_Bool = Comp_String("P" & "Q" & "R" & "S")
End Sub

Private Function Comp_String(strNew) As Boolean
Dim i As Integer
Dim strVer As String
'I don't know your table format
'so here you must make a conexion
StrVer = table.joint1.Value & table.joint2.Value ...
For i = 1 To Table.RecordCount
If strVer = strNew Then
Comp_String = False
Exit Function
Next i
Comp_String = True
End Function
 
Other solution:

depends your datasystem set a keyindex on the combination Joint1 & Joint2 & Joint3 & Joint4 and if you'll save you can verificate a double with a Error-funktion.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top