Do really long calculations cause problems? what am i doing wrong?[resolved]
heres my code for saving some info to an array
VB Code:
For h = 0 To Shp.ubound
For i = 0 To Shp.ubound
gravforcex(h, i) = (Shp(h).Left - Shp(i).Left) * (((Sqr(Sqr((Shp(h).Left - Shp(i).Left) ^ 2 + (Shp(h).Top - Shp(i).Top) ^ 2))) ^ -1 * 500) / (Sqr((Shp(h).Left - Shp(i).Left) ^ 2 + (Shp(h).Top - Shp(i).Top) ^ 2)))
gravforcey(h, i) = (Shp(h).Top - Shp(i).Top) * (((Sqr(Sqr((Shp(h).Left - Shp(i).Left) ^ 2 + (Shp(h).Top - Shp(i).Top) ^ 2))) ^ -1 * 500) / (Sqr((Shp(h).Left - Shp(i).Left) ^ 2 + (Shp(h).Top - Shp(i).Top) ^ 2)))
Next i
Next h
on the gravforcex(h,i) = blah line... it gives me an invalid procedure call or argument error.
shp is a shape control array, and its set up correctly... ive tested the top and left properties in other ways and they are working.
if u have any input itd be greatly appreciated
Re: Do really long calculations cause problems? what am i doing wrong?
Without even looking at formulas I'd recommend to "split" into variables so you can debug each value before the final cals.
Re: Do really long calculations cause problems? what am i doing wrong?
right... well the whole reasoning behind makeing that extremely large calculation was to speed up my program b/c i figured making 6 or 8 array variables in a loop would be much more time consuming than just rolling them all together... am i wrong in this assumption?
Re: Do really long calculations cause problems? what am i doing wrong?
Well, since you're working with numbers you really have little to worry about peformance - VB processes numbers extremly fast.
Re: Do really long calculations cause problems? what am i doing wrong?
ok thanx... what is it that makes vb so slow if it processes numbers so fast? isnt everything in a program essentially numbers?
Re: Do really long calculations cause problems? what am i doing wrong?
I don't quite understand your sarcasm. :rolleyes:
Under sircumstances VB6 can perform better than VC++, C#, VB.Net not to mention Java...
Re: Do really long calculations cause problems? what am i doing wrong?
really? thats not been my impression... ive always been told that c++ and c are way faster powerful languages
Re: Do really long calculations cause problems? what am i doing wrong?
It depends - you can't beat C++ in processing strings (perhaps OAK on UNIX will outperform it) but not numbers ...
Re: Do really long calculations cause problems? what am i doing wrong?
Quote:
Originally Posted by MET777
ok thanx... what is it that makes vb so slow if it processes numbers so fast? isnt everything in a program essentially numbers?
Strings
Working with Numbers is very fast in VB, actually VC++ time is just 15% faster than VB time.
Re: Do really long calculations cause problems? what am i doing wrong?[resolved]
you are probably trying to take the square root of a negative number.
Re: Do really long calculations cause problems? what am i doing wrong?[resolved]
Quote:
Originally Posted by MET777
... what is it that makes vb so slow ... ?
Quote:
Originally Posted by jcis
Strings ...
If it was that simple we could all leave with that ... I guess. :)
Actually relatively small strings are quite fast - it's the large ones that slow down things. Also variants, objects, bindings and so on and so forth. But over all I think VB6 is pretty darn good "performer" !!! :thumb: