Xuân Thanh > 18-04-12, 01:04 PM
Function TimKiemChuoi(ChuoiMe As String, ChuoiCon As String) As String
ChuoiMe = Trim(ChuoiMe): ChuoiCon = Trim(ChuoiCon)
LM = Len(ChuoiMe): LC = Len(ChuoiCon)
If LM < LC Then MsgBox "O la la!!!!! Sai roi!!!!!" & Chr(13) & "Me ngan hon con !", , "Chu y": Exit Function
Dim i As Integer
Dim Thay As Boolean
Thay = False
For i = 1 To LM - LC + 1
If Mid(ChuoiMe, i, LC) = ChuoiCon Then
Thay = True
Exit For
Else
Thay = False
End If
Next
If Thay = True Then
TimKiemChuoi = ChuoiMe
Else
MsgBox "Khong tim thay", , "Thong Bao"
End If
End Function
haquocquan > 18-04-12, 04:41 PM
Function TimKiemChuoi(ChuoiMe As String, ChuoiCon As String) As String
ChuoiMe = Trim(ChuoiMe): ChuoiCon = Trim(ChuoiCon)
If Len(ChuoiMe) < Len(ChuoiCon) Then
MsgBox "O la la!!!!! Sai roi!!!!!" & Chr(13) & "Me ngan hon con !", , "Chu y":
Exit Function
Else
Dim Thay As Boolean
Thay = False
If InStr(1, ChuoiMe, ChuoiCon) > 0 Then
Thay = True
Else
Thay = False
End If
If Thay = True Then
TimKiemChuoi = ChuoiMe
Else
MsgBox "Khong tim thay", , "Thong Bao"
End If
End If
End Function
duyhiep > 17-01-13, 10:24 PM