![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Not a user?
Join Date: Sep 2007
Posts: 256
Rep Power: 2
![]() |
indexof
Does VB05 have some kind of next occurrence for indexof in strings? I only see index of (first occurence) and lastindexof (last occurrence), but I find nothing to find next occurrence.
|
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Re: indexof
VB 5? Even I can't remember that far back. I think you'll want to look for string methods in general and see if you recognize something useful.
There are almost always methods for indexing a particular character (string [5], charAt [7], etc.) There's also generally a method for finding an occurrence of some particular character within the string.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 |
|
Not a user?
Join Date: Sep 2007
Posts: 256
Rep Power: 2
![]() |
Re: indexof
I'm sorry, I didn't make myself clear. I meant VB 2005. String has an indexof function, and a lastindexof function, but I don't see anything to iterate through all occurrences of a single char. I guess that's an oversight on their part. I'm gonna hate having to iterate them myself, as my code is starting to look a little bloated and this won't help it any.
|
|
|
|
|
|
#4 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Re: indexof
Ahhhh. You can get the character (or substring) at any position by using substr. You can search for a character (or substring) using inStr. Again, I'd recommend you look at the methods that are members of the class. These people set out to write things that are generally useful. They might not choose to restrict them unduly, or name them what one expects.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#5 |
|
Not a user?
Join Date: Sep 2007
Posts: 256
Rep Power: 2
![]() |
Re: indexof
Thanks, DaWei.
I guess the best place to look would be in the MSDN for the string class then? I've looked at everything that pops up when you hit the period after the string, but I guess it could be hidden deeper like under string.chars. To show the bloat, here's the sub, and the else statement at the end is where I really need this function. vb Syntax (Toggle Plain Text)
Last edited by Jabo; Nov 10th, 2007 at 1:04 AM. |
|
|
|
|
|
#6 |
|
Not a user?
Join Date: Sep 2007
Posts: 256
Rep Power: 2
![]() |
Re: indexof
Correction, the next to last else statement
|
|
|
|
|
|
#7 |
|
Not a user?
Join Date: Sep 2007
Posts: 256
Rep Power: 2
![]() |
Re: indexof
The way I've done this, seems to be the most round-about way one could possibly do it. I will try to find a better way
Starting line# 71 is the else I'm talking about. Last edited by Jabo; Nov 10th, 2007 at 3:23 AM. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|