- Tham gia
- 21/12/07
- Bài viết
- 1,902
- Được thích
- 5,303
- Nghề nghiệp
- Kinh doanh các mặt hàng văn phòng phẩm
Chào các bạn.
Nhờ các bạn tìm giúp lỗi trong đoạn code này nha.
Nếu mình dùng 1 dòng for thì chạy tốt, nhưng thêm một dòng nữa để tách lấy Tên lót thì bị lỗi.
Cảm ơn.
[/FONT][/COLOR]
Nhờ các bạn tìm giúp lỗi trong đoạn code này nha.
Nếu mình dùng 1 dòng for thì chạy tốt, nhưng thêm một dòng nữa để tách lấy Tên lót thì bị lỗi.
Cảm ơn.
Mã:
[COLOR=red]Function tachten(chuoi as string,loai as integer) as string[/COLOR]
[COLOR=red][FONT=Arial]Dim i As Integer[/FONT][/COLOR]
[COLOR=red][FONT=Arial]Dim j As Integer[/FONT][/COLOR]
[COLOR=red][FONT=Arial]ten = Trim(chuoi)[/FONT][/COLOR]
[COLOR=red][FONT=Arial]For i = 1 To Len(ten) Step 1[/FONT][/COLOR]
[COLOR=red][FONT=Arial]For j = Len(ten) To 1 Step -1[/FONT][/COLOR]
[COLOR=red][FONT=Arial]If (Mid(ten, i, 1) = " ") And (Mid(ten, j, 1) = " ") Then[/FONT][/COLOR]
[COLOR=red][FONT=Arial]If loai = "1" Then tachten = Left(ten, i - 1)[/FONT][/COLOR]
[COLOR=red][FONT=Arial]ElseIf loai = "2" Then tachten = Mid(ten, i + 1, j - i - 1)[/FONT][/COLOR]
[COLOR=red][FONT=Arial]ElseIf loai = "3" Then tachten = Right(ten, Len(ten) - j)[/FONT][/COLOR]
[COLOR=red][FONT=Arial]Else: MsgBox "tuy chon chi tu 1 den 3"[/FONT][/COLOR]
[COLOR=red][FONT=Arial]End If[/FONT][/COLOR]
[COLOR=red][FONT=Arial]End If[/FONT][/COLOR]
[COLOR=red][FONT=Arial]End If[/FONT][/COLOR]
[COLOR=red][FONT=Arial]Exit For[/FONT][/COLOR]
[COLOR=red][FONT=Arial]End If[/FONT][/COLOR]
[COLOR=red][FONT=Arial]Next j[/FONT][/COLOR]
[COLOR=red][FONT=Arial]Next i[/FONT][/COLOR]
[COLOR=red][FONT=Arial]End Function
Chỉnh sửa lần cuối bởi điều hành viên: