Results 1 to 10 of 10

Thread: String question?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    240

    Question

    I Was wondering..what is a better way to declare a string?
    Use a "M$" (for example) Or Is it better to use the
    Dim M As String?

    Thanks

  2. #2
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633

    Up to your preference!

    I like to Dim it better, but I heard that using Left$ will run much faster than Left.
    Chemically Formulated As:
    Dr. Nitro

  3. #3
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    Some clarifications I would like to point out

    Never use

    Dim M$

    always use

    Dim M as string

    those symbols are just there for backward compatibility, it is much more readable and maintainable to explictly declare the variable type.

    If a future programmer wants to maintain this code, they will have a tough time because they might have never had to write VB 3 code, so these symbols will be meaningless to them....

    based on my own benchmarks, the LEFT$ runs less than .1% faster than LEFT

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I don't thinks so, i'm using the !@#$%& more than ever because they take so little space and I think it's easier to read too, ie when you declare a function you will have the return type directly after the function name, and all arguments are easier to overview if they aren't spread out with as string and as integer and things.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845

    Clunietp gets my vote!

    Sorry kedaman but I agree with Clunietp in this one!
    Mark
    -------------------

  6. #6
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    I agree that for declaring variables, you should always use the "As datatype" clause. The special symbols are still in the language for backwards compatibility.

    However, for functions that return string values (such as Left, Mid, Trim, Format, etc.), I believe it is preferable to use the $ at the end. Without the $, these functions return a Variant data type rather than a string, so extra conversion steps are necessary.
    "It's cold gin time again ..."

    Check out my website here.

  7. #7
    Guest
    I too agree with Clunietp. M$, MyString$, Myint@ etc. all looks kind of like jargon when you look at the whole picture.

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Hmmm, Backward compability or not, it doesn't matter, I still have a very comprimized style and I'm sorry if other's have to use my code and don't like the special characters, if anyone could make a addin so you can change between using as vartype and special chars, I would be happy
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  9. #9
    Guest
    I never said that I didn't like them. I just think that you're making it look like jargon when you don't have to.

  10. #10
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    For me, it's the other way round
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width