# Length of a string withut using len function.

Page 1 of 1

## 3 Replies - 562 Views - Last Post: 09 August 2012 - 07:46 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=288369&amp;s=7de0d9e01318df5e7218340a20b75f3c&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Wolverine123

Reputation: 0
• Posts: 1
• Joined: 08-August 12

# Length of a string withut using len function.

Posted 08 August 2012 - 10:52 PM

Is it any way possible to find out the length of a string without using LEN function.
Can someone enlighten me on this, as i am new in VB coding.
Is This A Good Question/Topic? 0

## Replies To: Length of a string withut using len function.

### #2 Martyr2

• Programming Theoretician

Reputation: 3873
• Posts: 11,408
• Joined: 18-April 07

## Re: Length of a string withut using len function.

Posted 08 August 2012 - 11:14 PM

Is it any way possible to tell me what color the sky is without using the name of a color?

Doesn't make much sense right. Any particular reason why you want to avoid the function that gives you the exact answer to the question?

I suppose you could create a loop through Mid(). Start the length you supply to the function with 1 and keep increasing it until the value returned by Mid() is equal to the string.

```Dim i as Integer

i = 1

Do While Mid("someString",0,i) <> SomeString
i = i + 1
Loop

```

Once this code finishes, "i" should be the length of "SomeString". Of course I think Len() is just a safer bet.

### #3 Neku

• D.I.C Regular

Reputation: 18
• Posts: 255
• Joined: 21-May 09

## Re: Length of a string withut using len function.

Posted 09 August 2012 - 06:55 AM

Len() was invented so you wont have to write your own text length calculating function.
why bother to find different way?

### #4 maj3091

• D.I.C Lover

Reputation: 273
• Posts: 1,635
• Joined: 26-March 09

## Re: Length of a string withut using len function.

Posted 09 August 2012 - 07:46 AM

Come on OP, give us the reason why you can't / don't want to use the LEN function.