Vj

The next Click event procedure uses the StrComp function to determine the equality of two strings. Figure 5.4 examines sample output from the event procedure.

Using the StrComp to compare two strings for equality.

Using the StrComp to compare two strings for equality.

Private Sub cmdCompareStrings_Click()

Dim iResult As Integer iResult = StrComp(txtFirstString.Value, txtSecondString.Value)

Select Case iResult

Case -1

MsgBox "The first string is less than the second."

Case 0

MsgBox "Both strings are equal."

Case 1

MsgBox "The first string is greater than the second." Case Else

MsgBox "One or more strings are Null." End Select

End Sub

Right

The Right function takes two parameters and returns a string containing the number of characters from the right side of a string. The first parameter is the evaluated string. The second parameter is a number that indicates how many characters to return from the right side of the string. Sample output is shown in Figure 5.5.

Private Sub cmdExtract_Click()

txtOutput.Value = Right(txtInput.Value, 3) End Sub

Extracting three characters from the right side of a string.

' Microsoft Access - [Forml Forti|

Jnjx]

HI File Edit View Insert Format Records Tools' Window Help _ 3 x d avi * ^ ft

Tahoma

0 0

Post a comment