Why is x the most used variable in both programming and algebra?Code:x = string
Printable View
Why is x the most used variable in both programming and algebra?Code:x = string
Its the X-factor... That which is unknown.
X marks the spot.
X usually means something is unknown.
If you have a calculation like
Fine, but it should not be used where a more meaningful variable name could be used e.gCode:
x = x + variableamt.
Just pointing out the relative merits of naming variables. We do allow "x" etc to be used as For...Next counters etc.Code:
totSales = totSales + Sale_Qty
CustName = CustName & " " & Last_Name
My $0.01c worth.:)
Jethro,
No we don't allow "x" in For...Next loops...
We use "iNum" or "iCount" or "iLoop" instead. :D
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 :confused: ) I use things like strMyRelavantVarName.
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
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.
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
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!
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
Mine is as follows.Quote:
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
- 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
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