Thread

Need Help.. (Sdk)

Need Help.. // Sdk

1  |  

lanezeri

Mar 17, 2001, 3:44pm
Hey.. I cant get the stupid thing to add a simple number..

say I have this..

My Balance = 500
Friend Balance = 500

I transfer 300 to him.

My New Balance = 200
His New Balance = 500300

I mean.. his balance should be 800, I used this format.. X + Y not X & Y

Please try to help me.. someone..

--
- = [ T e c h n o ] = -
http://wt.s5.com
- = [ S t u f f - X ] = -
http://www.stuffx.com/aw

andras

Mar 17, 2001, 5:45pm
[View Quote]

lanezeri

Mar 17, 2001, 6:24pm
I dont use them as nothing.. u mean like "Dim X as String" and stuff

--
- = [ T e c h n o ] = -
http://wt.s5.com
- = [ S t u f f - X ] = -
http://www.stuffx.com/aw

grimble

Mar 19, 2001, 7:14pm
I think this says a lot really ...

[View Quote]

xelag

Mar 19, 2001, 7:25pm
Try this: 1 * X + Y

This makes sure you are dealing with numbers if you use variants.

XelaG

[View Quote]

grimble

Mar 19, 2001, 7:42pm
OK ... ONE quick lesson ... since you're leaving soon.

If you don't predeclare your variables within a scope, and there is no
appropriate letter range defined for a variable's name(using DefBool,
DefInt, DefStr, etc.), the variable will be defined as a variant. Variant
data types are "anything"s and take their characteristics from the source
value when assigned. For example, if you assign it from a string value, the
variant will act as a string, if you put a number in there, it will act as a
number.

The recommendation is to force predeclaration of all variables using "Option
Explicit" (look it up in the help) by setting the "Require Variable
Declaration" flag under Tools | Options | Editor. Then, all variables used
in your code must be declared within the scope in which it is used.

You should ALWAYS know what your variable's behaviour is going to be. In
your example, you have managed to set the value of the variable from a
string value (maybe from a textbox ??) and for strings, the "+" operator
acts in the same way as a "&" operator.

Use "Require Variable Declaration" and add "Option Explicit" to the top of
all your existing forms, modules and classes and do a full recompile
(CTRL=F5) and sort any new errors you may get. Good programming practice
dictates that you predelcare all variables anyway ... VB's ability to
override it is one of those little quirks that is there purely for
supporting legacy code - its an old BASIC thing. Its a little annoying that
the default setting is "off" really. All other programming languages I have
dealt with DEMAND that predecs are made.

Read the VB help files for Dim, Public, Private and Option Explicit. I would
say that any chance of a decent programmer "buying" one of your bots has
just gone out of the window, "bud".

Grims


[View Quote]

1  |  
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn