3 Replies - 562 Views - Last Post: 09 August 2012 - 07:46 AM Rate Topic: -----

#1 Wolverine123  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 3873
  • View blog
  • 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.

:)
Was This Post Helpful? 0
  • +
  • -

#3 Neku  Icon User is offline

  • D.I.C Regular

Reputation: 18
  • View blog
  • 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?
Was This Post Helpful? 0
  • +
  • -

#4 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 273
  • View blog
  • 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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1