Ironworks Gaming Forum

Ironworks Gaming Forum (http://www.ironworksforum.com/forum/index.php)
-   General Conversation Archives (11/2000 - 01/2005) (http://www.ironworksforum.com/forum/forumdisplay.php?f=28)
-   -   VB Question (http://www.ironworksforum.com/forum/showthread.php?t=84648)

LennonCook 03-14-2003 01:15 AM

<font color="lightblue">Ok, I think I see a mod() command being used alot... but converting back to decimal could pose a problem...
Maybe I should work on Binary - Octal - Decimal and back first; atleast that won`t have me dealing with letters... </font>

Night Stalker 03-15-2003 02:25 AM

Actually going from hex to dec is really easy -> treat it as a string and process each char separately in a loop. Handle A-F in a case statement. This by any chance wouldn't be homework? Anyway the prototype would be:

function HexToDec(strHexNum as string) as long

GokuZool 03-15-2003 05:25 AM

[img]graemlins/wow.gif[/img] Whoa! All this stuff looks so complicated!

There I was thinking this would a topic about VB's (as in the beer) :D

/)eathKiller 03-15-2003 06:34 AM

*tsk tsk tsk* All this visual basic stuff is just .. hard... it's like another language... err it is.... but honestly... I'm a sever hater of VB myself, and I don't mind voicing my opinoin on being Pro-Java... So its more complicated, yeah well at least I can freaking understand what i'm puttin in [img]tongue.gif[/img] I think my favorite code to go with, though, it HTML... [img]tongue.gif[/img]

oh right back to my opinion:

C will live forver! yarr! Even if it goes under the name Java and C#...

there... [img]tongue.gif[/img]

Now with that visual basic question...

Night stalker just gave you the answer so theres no pont in my working on it [img]tongue.gif[/img]

aaaand im so tired i'm just gonna go to sleep now...

andrewas 03-15-2003 07:17 AM

Regarding the VB stuff we were talking about last night (OK, it was morning for you, who cares), theres a minor bug in the code I gave you.

This is why I use 2d arrays for crap like this, but I guess were stuck with a 1d now.

Anyway, 8 MOD 8 is 0.

So "if index mod 8 < 6" will return true when dealing with column 8, which screws up the whole function. Ill leave the corrections up to you.

And LEARN C. Its faster, more efficient, more powerful, and looks better on your CV.

Charlie 03-15-2003 07:29 AM

Quote:

Originally posted by andrewas:
Regarding the VB stuff we were talking about last night
This is why I use 2d arrays for crap like this, but I guess were stuck with a 1d now.

Anyway, 8 MOD 8 is 0.

So "if index mod 8 < 6" will return true when dealing with column 8, which screws up the whole function. Ill leave the corrections up to you.

And LEARN C. Its faster, more efficient, more powerful, and looks better on your CV.

Well I'm super efficient with everything you've taught me so far. I've got 8 Mods for 2d which = 1d index< mod head explosion.
I,ve learnt C but I'm having trouble with the V for my CV.

Can you help....can you? Please, I was doing so well up till then. ;)

LennonCook 03-15-2003 08:53 AM

Quote:

Originally posted by andrewas:
Regarding the VB stuff we were talking about last night (OK, it was morning for you, who cares), theres a minor bug in the code I gave you.

This is why I use 2d arrays for crap like this, but I guess were stuck with a 1d now.

Anyway, 8 MOD 8 is 0.

So "if index mod 8 < 6" will return true when dealing with column 8, which screws up the whole function. Ill leave the corrections up to you.


<font color="lightblue">What about "If index mod 8<6 And Index <> 8" ?? </font>

LennonCook 03-15-2003 08:56 AM

Quote:

Originally posted by Night Stalker:
Actually going from hex to dec is really easy -> treat it as a string and process each char separately in a loop. Handle A-F in a case statement. This by any chance wouldn't be homework? Anyway the prototype would be:

function HexToDec(strHexNum as string) as long

<font color="lightblue">No, it isn`t homework... just a personal excercise... along with Connect Four, Guess the Number, and learning some other, more powerful, language... maybe German ?? Seemed to work for Hitler...

I`m not quite sure I understand how to process each character separately... hints, maybe ?? [img]smile.gif[/img]
And is a Function the same thing as a Sub ?? Is one considered more correct over the other ??

And while i`m in a question mood, what is the difference between telling it to "End" and telling it to "Unload Me" ??</font>

[ 03-15-2003, 09:00 AM: Message edited by: LennonCook ]

andrewas 03-15-2003 11:09 AM

1) Think why If index >3 didnt work earlier.

2)

Learn C.

You can handle a string as an array, and FOR through it.

Sub and Function are similar, functions return a value, Subs dont.

So you could set

a = function(b)

but not

a = sub(b)

I have no idea on the end thing. I guess that end is equivalent to a C++ destructor, which cleans up the object then deletes it so you dont have any dead ends, whereas unload me would be equivalent to the free() function. End sounds safer. But Im guessing here.

Night Stalker 03-15-2003 11:59 AM

End is a forceful shutdown to the whole program, ungracefully.

Unload object is the class destructor.

A function returns a value, a sub does not. Useing x=sub() will cause an error.

Yes strings are just null terminated charactor (byte) arrays. I forget if VB will let you index a string directly or not. If not you can use the mid funtcion in the for loop.

</font><blockquote>code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">function HexToDec( HexNum as string) as long
dim strDigit as string
dim lngTempRslt as long
dim i as integer

for i = 1 to len(HexNum)
strDigit = Mid(i, HexNum, 1) '&lt;:-- check the prototype for mid

select case strDigit
case &quot;a&quot;
lngTempRslt = (10 * 10^(i - 1)) + lngTempRslt
.
.
.
case else
lngTempRslt = CLong(strDigit) * 10^(i - 1) + lngTempRslt
end select
next

end function</pre>[/QUOTE]There's a really big hint ... good luck.


All times are GMT -4. The time now is 02:43 PM.

Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
©2024 Ironworks Gaming & ©2024 The Great Escape Studios TM - All Rights Reserved