Results 1 to 13 of 13

Thread: Variable?

  1. #1
    Guest
    Code:
    x = string
    Why is x the most used variable in both programming and algebra?

  2. #2
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    Its the X-factor... That which is unknown.

    X marks the spot.

  3. #3
    Guest
    X usually means something is unknown.

  4. #4
    Guest

    Thumbs up x is good for maths but

    If you have a calculation like

    Code:
    x = x + variableamt.
    Fine, but it should not be used where a more meaningful variable name could be used e.g

    Code:
    totSales = totSales + Sale_Qty
    
    CustName = CustName & " " & Last_Name
    Just pointing out the relative merits of naming variables. We do allow "x" etc to be used as For...Next counters etc.

    My $0.01c worth.

  5. #5
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    Jethro,

    No we don't allow "x" in For...Next loops...

    We use "iNum" or "iCount" or "iLoop" instead.

  6. #6
    Guest
    Most of the time I use i in For...Next loops, so I dont have to use a long variable name, but when I am doing something else, like assigning a variable to a string(or is it the other way around ) I use things like strMyRelavantVarName.

  7. #7
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    Why add an entire 3 letters? (ie str)

    Why not just add 1 letter? (s)


    sMyRelevantStringName
    iMyIntegerName
    lMyLongName
    oMyObject
    dMyDate

    I usually only go to 3 letter when defining form items :

    frmFormName
    txtTextBox
    lstListBox
    cboComboBox
    fraFrame

  8. #8
    Guest
    well, usually when I use strings, I dont use str usually I just have the variable name. But for stuff like long I use lng, thanks for the tip(only using 1 letter), I have seen that used before, but was too lazy to ummmm.... too lazy to type the rest of this post, but anyway thanks.

  9. #9
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Personally I use the following hungerian notation:

    s = String
    i = Integer
    lng = Long, I don't use l because it's easy to confuse with a capital i (Which I use for interface classes)
    sng = Single, as stated above I already use s for strings
    b = Byte
    bln = Boolean, I use b for Byte
    d = Date
    dbl = Double

  10. #10
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Simple Matthew:
    Programming!
    We've all been programed via school etc. Why is a chair a chair and not a table? Someone, way down the chain said it was a chair and so it is, because it's been handed down.
    For example:
    Right now everyone is taught to make their programs simulate MS as that is the way it should be done..ie..Shortcut = Ctrl X for exit. They say we should do it that way because everyone is already familuar with that context and so we do.....did you ever use Ctrl E for exit...I don't think so...and if you did it was a one time thing.

    Programming...all our lives we are being programmed!


    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  11. #11
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Default variables

    Used with your own code you could have some variables that you always use for a specific purpose:

    x,y,z - coordinates
    x,temp - temporary values
    w,h,dX, dY, dz... - dimensions, differences
    ff - filenumber
    alfa, beta - angles
    a1, x1 - indexed
    vx, vy - velocities
    vr - vectors
    n,s - counters in loops
    newvalue - last argument in property let

    and a lot more
    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.

  12. #12
    Guest
    Originally posted by Joacim Andersson
    Personally I use the following hungerian notation:

    s = String
    i = Integer
    lng = Long, I don't use l because it's easy to confuse with a capital i (Which I use for interface classes)
    sng = Single, as stated above I already use s for strings
    b = Byte
    bln = Boolean, I use b for Byte
    d = Date
    dbl = Double
    Mine is as follows.
    • String: sVar
      Integer: iVar
      Long: lVar, dwVar (dw represents DWORD)
      Handle: hVar
      Boolean: bVar
      Byte: chVar, cVar (c represents the C++ eqv. Char)
      Date: dtVar
      Single: sngVar
      Double: dblVar
      Currency: curVar
      Double: dblVar

  13. #13
    Guest
    this is what I have been using.
    Code:
    Integer = iVar
    Long = lngVar
    Double = dblVar
    Boolean = blnVar
    Byte = bVar
    Currency = curVar
    Date = dtVar
    Object = objVar
    String = strVar
    hWnd = hwndVar
    Region = rgnVar

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