+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Other way to declare Variables using Symbols

  1. #1
    Join Date
    Jun 2007
    Location
    Kosovo
    Posts
    660
    Rep Power
    23

    Other way to declare Variables using Symbols

    Ok this will be a pretty small tutorial ok you know all how to declare variables in vb6 & vb .NET right
    ex
    Code:
    Dim TheString as String
    Dim Number as Integer
    but did you know that you can declare a variable in a much shorter way using symbols like this


    Code:
    Dim TheString$ 'String
    Dim TheInt% 'Integer
    Dim TheSingle! 'Single
    Dim TheDouble# 'Double
    Dim TheLong& 'Long
    Dim TheCurrency@ 'Currency
    so i also commented each line so you know what symbol do what but let me write it down

    % - Integer
    ! - Single
    # - Double
    & - Long
    @ - Currency

    Ok this is the tutorial i know realy short but i hope i can get in handle for anyone of you Peace out
    Last edited by kresh7; 09-18-2009 at 06:54 AM.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Jordan Guest

    Re: Other way to declare Variables using Symbols

    I've never heard of these declaration shortcuts in VB. Very good to know! +rep

  4. #3
    Join Date
    Aug 2009
    Location
    ~/
    Posts
    918
    Rep Power
    19

    Re: Other way to declare Variables using Symbols

    This was the old way of doing it (back in basic, basicA, gwbasic, qbasic, etc...)

    VB tries to support legacy commands and conventions
    (with minimal to no documentation) as long as it doesn't
    go against it's current direction.

    I'm a nostalgia buff, so good post +rep

  5. #4
    Join Date
    Jun 2007
    Location
    Kosovo
    Posts
    660
    Rep Power
    23

    Re: Other way to declare Variables using Symbols

    Quote Originally Posted by debtboy View Post
    This was the old way of doing it (back in basic, basicA, gwbasic, qbasic, etc...)

    VB tries to support legacy commands and conventions
    (with minimal to no documentation) as long as it doesn't
    go against it's current direction.

    I'm a nostalgia buff, so good post +rep
    Excualy i seen the first string $ declaration in a QBasic code then i was wounding what it was.After reading a little and trying in VB6 i found it out xD
    Sometimes taking a deep look into source code can make you learn a lot new stuff thx for the replies to my post

  6. #5
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: Other way to declare Variables using Symbols

    That's a cool bit of info. +rep
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  7. #6
    Join Date
    Mar 2008
    Posts
    7,145
    Rep Power
    86

    Re: Other way to declare Variables using Symbols

    Very interesting. I prefer the "as" method even though it is more typing because it reads a lot easier. When I see

    Code:
    Dim sName$
    I have to remember what $ means, where as

    Code:
    Dim sName As String
    I don't have to remember anything. It reads easier.

  8. #7
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: Other way to declare Variables using Symbols

    It is useful when declaring constants, though:

    Code:
    Const MyLongConst = &HFACE&
    Const MyIntConst = &HFACE%
    I'm not really a .NET person so I don't know if they fixed this, but this is the way it was done in 6 and VBA.
    sudo rm -rf /

  9. #8
    Join Date
    Oct 2008
    Location
    Istog, Kosova
    Posts
    4,001
    Blog Entries
    1
    Rep Power
    40

    Re: Other way to declare Variables using Symbols

    Cool!
    Interested in participating in community events?
    Want to harness your programming skill and turn it into absolute prowess?
    Come join our programming events!

  10. #9
    so1i's Avatar
    so1i is offline Programming Professional
    Join Date
    Sep 2009
    Location
    Aberystwyth, United Kingdom
    Posts
    309
    Rep Power
    0

    Re: Other way to declare Variables using Symbols

    This is really cool, I never knew you could do it that way!

  11. #10
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: Other way to declare Variables using Symbols

    I would advise against it, just because it makes your program annoying to read.
    sudo rm -rf /

+ Reply to Thread
Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Declare Public Array?
    By DrillR in forum Visual Basic Programming
    Replies: 2
    Last Post: 05-04-2011, 02:04 PM
  2. Replies: 3
    Last Post: 04-26-2010, 04:16 AM
  3. How to declare 15 digits variable?
    By mokszyk in forum C and C++
    Replies: 7
    Last Post: 06-20-2009, 03:26 AM
  4. Replies: 3
    Last Post: 04-20-2008, 11:18 AM
  5. Question regarding symbols
    By soliver1982 in forum HTML Programming
    Replies: 2
    Last Post: 01-02-2007, 03:26 PM

Tags for this Thread

Bookmarks

Posting Permissions

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