30.07.2013 Views

Visual Basic.NET How to Program (PDF)

Visual Basic.NET How to Program (PDF)

Visual Basic.NET How to Program (PDF)

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 15 Strings, Characters and Regular Expressions 645<br />

19<br />

20 output &= vbCrLf & """$"" is located at index " & _<br />

21 letters.IndexOf("$"c, 3, 5)<br />

22<br />

23 ' test LastIndexOf <strong>to</strong> find a character in a string<br />

24 output &= vbCrLf & vbCrLf & "Last ""c"" is located at " & _<br />

25 "index " & letters.LastIndexOf("c"c)<br />

26<br />

27 output &= vbCrLf & "Last ""a"" is located at index " & _<br />

28 letters.LastIndexOf("a"c, 25)<br />

29<br />

30 output &= vbCrLf & "Last ""$"" is located at index " & _<br />

31 letters.LastIndexOf("$"c, 15, 5)<br />

32<br />

33 ' test IndexOf <strong>to</strong> locate a substring in a string<br />

34 output &= vbCrLf & vbCrLf & """def"" is located at" & _<br />

35 " index " & letters.IndexOf("def")<br />

36<br />

37 output &= vbCrLf & """def"" is located at index " & _<br />

38 letters.IndexOf("def", 7)<br />

39<br />

40 output &= vbCrLf & """hello"" is located at index " & _<br />

41 letters.IndexOf("hello", 5, 15)<br />

42<br />

43 ' test LastIndexOf <strong>to</strong> find a substring in a string<br />

44 output &= vbCrLf & vbCrLf & "Last ""def"" is located " & _<br />

45 "at index " & letters.LastIndexOf("def")<br />

46<br />

47 output &= vbCrLf & "Last ""def"" is located at " & _<br />

48 letters.LastIndexOf("def", 25)<br />

49<br />

50 output &= vbCrLf & "Last ""hello"" is located at " & _<br />

51 "index " & letters.LastIndexOf("hello", 20, 15)<br />

52<br />

53 ' test IndexOfAny <strong>to</strong> find first occurrence of character<br />

54 ' in array<br />

55 output &= vbCrLf & vbCrLf & "First occurrence of ""c""," & _<br />

56 " ""a"" or ""$"" is located at " & _<br />

57 letters.IndexOfAny(searchLetters)<br />

58<br />

59 output &= vbCrLf & "First occurrence of ""c"", ""a"" or " & _<br />

60 """$"" is located at " & _<br />

61 letters.IndexOfAny(searchLetters, 7)<br />

62<br />

63 output &= vbCrLf & "First occurrence of ""c"", ""a"" or " & _<br />

64 """$"" is located at " & _<br />

65 letters.IndexOfAny(searchLetters, 20, 5)<br />

66<br />

67 ' test LastIndexOfAny <strong>to</strong> find first occurrence of character<br />

68 ' in array<br />

69 output &= vbCrLf & vbCrLf & "Last occurrence of ""c""," & _<br />

70 " ""a"" or ""$"" is located at " & _<br />

71 letters.LastIndexOfAny(searchLetters)<br />

Fig. 15.6 Searching for characters and substrings in Strings (part 2 of 3).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!