Useful VB hash code

Talk about game development and programming, and let people know about your own projects!
Post Reply
User avatar
Will
Makes Useless Posts
Posts: 268
Joined: October 23rd, 2004, 9:40 pm

Useful VB hash code

Post by Will » December 2nd, 2004, 7:12 pm

Have you ever wanted to associate variables with strings, and be able to look them up quickly without searching through thousands of entries?

I've written some useful code that does this, and it's very fast and reliable. I stress-tested it and even with about 1.5 million strings in the database, thousands of lookups can be made per second.

Here is an example of what it does:

addword "This is a sample string", 1337 ' Associate the number 1337 with the string

...

Later on in the code:

'What number did we associate with that string?

number = getdata("This is a sample string")

'number will now contain 1337.

Millions of strings can be added with virtually no speed penalty. It is fast enough so that thousands of words can be added / looked up per second. The only drawback is that words cannot be removed (yet)

Other useful functions:

getword: This returns a string from the database given an "ID" (this ID is actually the end node of a string in radix tree)

The ID of strings can be found with the sub findendnode(string)

for example:

addword "Huge faggot", 100

id = findendnode("Huge faggot")

debug.print getword(id)

This will print the stored string in the database. Note that addword will also return this information, however findendnode will not overwrite the data associated with the string


If anyone wants the code, give me a shout

User avatar
Will
Makes Useless Posts
Posts: 268
Joined: October 23rd, 2004, 9:40 pm

Post by Will » December 2nd, 2004, 7:15 pm

Oops, that post was by me! For some reason I wasn't logged in
-Will

Aloshi
Magic Number 400
Magic Number 400
Posts: 401
Joined: September 13th, 2005, 9:34 pm
Location: USA

Post by Aloshi » October 13th, 2005, 12:53 pm

What was Afterlife programed in? And where the HECK can you get Visual Basic 6.0? I took a class for programming and only got to use Visual Basic 6, and I want the program so that I can use what I learned. I searched MSN, Search.com, Microsoft's site, Officemax's site and Walmat's site, but STILL never saw anything about where to get it!! Where can I get it?!? :( x 4

Balloony
Star Player!
Star Player!
Posts: 262
Joined: February 26th, 2005, 10:29 am

Post by Balloony » October 13th, 2005, 3:10 pm

Probably anywhere as a boxed version, just because VB 6 is outdated. The newest version of Visual Basic is ".NET 2003", which you can buy at Amazon.co.uk for example:
http://www.amazon.co.uk/exec/obidos/ASI ... 56-7667656

The only way I know how to get VB 6 is buying a tutorial/crash course book for beginners, where you have "all inclusive", which means into the book you'll find a CD with VB 6.0 Standard. Such books cost about 20-30€.
Although I would still buy the newest version if you want to start with some serious project.

Edit: If you buy the .NET 2003, don't forget to download the .NET framework: http://www.microsoft.com/downloads/deta ... 4d1e7cf3a3
Last edited by Balloony on October 13th, 2005, 6:36 pm, edited 2 times in total.
"Time flies like an arrow, fruit flies like a banana." -Groucho Marx

User avatar
Will
Makes Useless Posts
Posts: 268
Joined: October 23rd, 2004, 9:40 pm

Post by Will » October 13th, 2005, 6:20 pm

Afterlife was made in VB6
-Will

Aloshi
Magic Number 400
Magic Number 400
Posts: 401
Joined: September 13th, 2005, 9:34 pm
Location: USA

Post by Aloshi » October 13th, 2005, 8:20 pm

Thank you Balloony (And Will!), I appreciate that a great deal. (Though I don't quite plan on a "Serious Project", but merely to make a small game, or something :)). A while ago, I made a really good calculator (It had the four basic operations, to the power of, %, and I also added squared) in the Visual Basic section included in Microsoft Word 2002, but I wish that I could make it an .EXE, because that one doesn't let you make .EXEs. :(

Anyways, thanks all. I have a few other questions: 1. (For VB programers) How do you set it two do things with a key? I was planning on making a small game sometime, but I can't if I can't use the arrow keys. 2. Is "Visual Studio" like VB? I have seen people talk about it elsewhere. And last: 3.Does Visual .NET 2003 (or whatever :P) work a lot like VB 6? Otherwise, I'll make more of an efort to find a bundle like the one you mentioned.

Again, thatnk you. I think I'll go play Afterlife in a bit. I got frustrated and haven't played in 3 and a half weeks. :P

Balloony
Star Player!
Star Player!
Posts: 262
Joined: February 26th, 2005, 10:29 am

Post by Balloony » October 13th, 2005, 9:25 pm

Thank you Balloony (And Will!), I appreciate that a great deal. (Though I don't quite plan on a "Serious Project", but merely to make a small game, or something ). A while ago, I made a really good calculator (It had the four basic operations, to the power of, %, and I also added squared) in the Visual Basic section included in Microsoft Word 2002, but I wish that I could make it an .EXE, because that one doesn't let you make .EXEs.
Yeah, the interface in Word is only intended for macros (small routine applications) as far I know. You can't compile them to executables.
Btw, Check out Winfunktion or Mapple, there you get a really good calculator ;)
I have a few other questions: 1. (For VB programers) How do you set it two do things with a key? I was planning on making a small game sometime, but I can't if I can't use the arrow keys. 2. Is "Visual Studio" like VB? I have seen people talk about it elsewhere. And last: 3.Does Visual .NET 2003 (or whatever ) work a lot like VB 6? Otherwise, I'll make more of an efort to find a bundle like the one you mentioned.
1. No clue, I'm only a bit used to PHP :P . But it should be a fairly easy function as you find something like that often in programming tutorials of other languages.
2. Yes and no. It is an extended version of VB with lots of functions you'll never need. That's also why it is not intended for avocation game programming or somewhat nonprofessional application. It's only used by pro's and developers, which do programming as their job.
3. Yes, I think so. Because its just the newest version of the same application with some slighty improved cosmetics and extended functions. It is well possible that you need some time to get used with but there shouldn't occur any major problems.

For more informations just ask Will. He knows a lot more about that stuff :P

Greetz

Balloony

Edit: Sorry, the newest version is .NET 2005 not 2003!
"Time flies like an arrow, fruit flies like a banana." -Groucho Marx

Aloshi
Magic Number 400
Magic Number 400
Posts: 401
Joined: September 13th, 2005, 9:34 pm
Location: USA

Post by Aloshi » October 23rd, 2005, 9:49 pm

OK, smart programer dudes: What is the command to use key presses in VB?? :)

Aloshi
Magic Number 400
Magic Number 400
Posts: 401
Joined: September 13th, 2005, 9:34 pm
Location: USA

Post by Aloshi » January 1st, 2006, 3:11 am

Sorry for double post, but:

I GOT VB.NET!! W00T! I need help, too...hehe...Anyways, is there a way to make anything in between 2 numbers? 'Cuz I need to make it a value to a value which is used in an IF statment...

2. Uh...How do you make it so that if a textbox has letters or not a number it will detect it? (Also in combination with an IF statment...)?

3. Last, how do I make a key have an action?

And I made a prog too. :D I will upload...Here is a link:
EDIT: Dang, user files don't support EXE's! I will upload in a .zip...

http://www.rjbsoftware.uk/userfiles/ ... yseven.zip

Please inform me of any bugs/cheats/etc.!

User avatar
Will
Makes Useless Posts
Posts: 268
Joined: October 23rd, 2004, 9:40 pm

Post by Will » January 1st, 2006, 12:10 pm

Remind me to post information when I'm less tired, my god I feel like crap at the moment and I can't think
-Will

Aloshi
Magic Number 400
Magic Number 400
Posts: 401
Joined: September 13th, 2005, 9:34 pm
Location: USA

Post by Aloshi » January 1st, 2006, 7:33 pm

Updated! I have the source with it now, and I added a File menu so I could clean up a few of the buttons! More to come later...;)
And, uh...Still waiting on those questions...

Balloony
Star Player!
Star Player!
Posts: 262
Joined: February 26th, 2005, 10:29 am

Post by Balloony » January 1st, 2006, 10:42 pm

It apparently says:

"The application could not be initialized (blahblahblahxblah) Press OK to close application".

Broken? Or do we need some libraries?
"Time flies like an arrow, fruit flies like a banana." -Groucho Marx

Aloshi
Magic Number 400
Magic Number 400
Posts: 401
Joined: September 13th, 2005, 9:34 pm
Location: USA

Post by Aloshi » January 2nd, 2006, 12:29 am

Hmm...I will take out the clock (I have NO idea why I put one in...) as it seems to cause problems. And I have HEAVILY updated. :)

Some new features are Secrets (:D) and a wins/losses counter. Not much in secrets yet, though...

Re-download it please for the newest version.
If anyone wants the password (And/or what it does (If you didn't already guess :roll:)) PM me.

@Balloony: Heh, I have no idea why that would be happening. Re download and tell me what happens. (And thanks for informing me :))

Balloony
Star Player!
Star Player!
Posts: 262
Joined: February 26th, 2005, 10:29 am

Post by Balloony » January 2nd, 2006, 9:53 am

@Balloony: Heh, I have no idea why that would be happening. Re download and tell me what happens. (And thanks for informing me )
It still displays a dialog box with the content I wrote above :| . Oh and if it helps: In the brackets there is a errorcode 0xc0000135
"Time flies like an arrow, fruit flies like a banana." -Groucho Marx

Aloshi
Magic Number 400
Magic Number 400
Posts: 401
Joined: September 13th, 2005, 9:34 pm
Location: USA

Post by Aloshi » January 2nd, 2006, 9:36 pm

Hmmm...I am not too good with errors. :?

Maybe try installing the .NET framwork if it isn't already? (You can do a search for it)

I will try a debugging version and see if I get any problems... :(

Aloshi
Magic Number 400
Magic Number 400
Posts: 401
Joined: September 13th, 2005, 9:34 pm
Location: USA

Post by Aloshi » January 2nd, 2006, 11:57 pm

Sorry for double post, but updated again. One new addition to the secrets menu...Sorta. I found some COMPLETELY useless code. (:P) wich has been deleted. And, I made a file option that sends you to the d/l link. What I need is small page or something to keep a list of new features/changes and an official download link (So I don't have to link to Ryan's link and to the forums for the changes :roll:). :? Any suggestions?:P

Balloony
Star Player!
Star Player!
Posts: 262
Joined: February 26th, 2005, 10:29 am

Post by Balloony » January 3rd, 2006, 10:42 am

Aloshi wrote:Hmmm...I am not too good with errors. :?

Maybe try installing the .NET framwork if it isn't already? (You can do a search for it)

I will try a debugging version and see if I get any problems... :(
Actually I prefer to be able to run such programs without downloading
other stuff.

In addition, I'm pretty sure that you can do this independently to the framework. Just take Ryan's progs as an example, where you only need libraries that are avaible in default OS ;)
"Time flies like an arrow, fruit flies like a banana." -Groucho Marx

Aloshi
Magic Number 400
Magic Number 400
Posts: 401
Joined: September 13th, 2005, 9:34 pm
Location: USA

Post by Aloshi » January 3rd, 2006, 1:32 pm

Eh, OK. I couldn't get the Debugger to work (It is just doing a release version for some reason)...:(

Heh, don't quite understand what you mean about Ryan's progs though...

Balloony
Star Player!
Star Player!
Posts: 262
Joined: February 26th, 2005, 10:29 am

Post by Balloony » January 3rd, 2006, 3:19 pm

Aloshi wrote:Heh, don't quite understand what you mean about Ryan's progs though...
Well they need VB Runtime libraries (already avaible in XP basic config) and your proggy needs the NET-Framework (must be downloaded additionally)

Btw, as it runs now, a little design tip: change the bet and the cash number colors from grey/black to white. dark colors on dark colors aren't very well visible ;)
In other respects it's quite nice :). Coded it all yourself or with a tutorial?
"Time flies like an arrow, fruit flies like a banana." -Groucho Marx

Aloshi
Magic Number 400
Magic Number 400
Posts: 401
Joined: September 13th, 2005, 9:34 pm
Location: USA

Post by Aloshi » January 3rd, 2006, 9:10 pm

Thanks for design tip, glad it works now too. :)
And 95%, or so, by me. All the tutorial had was the name (Which I may change soon, any suggestions?) and just the picture showing code and how to detect if you won. I got the pic from a google search. I am thinking about making a sound for when you win...:) The bet, win/lose counter, money system,The thing that says you won, the password stuff, secrets, and the entire file menu and secrets menu, etc. are all by me! Lots added from original, eh? :)

Aloshi
Magic Number 400
Magic Number 400
Posts: 401
Joined: September 13th, 2005, 9:34 pm
Location: USA

Post by Aloshi » January 4th, 2006, 1:04 am

Sorry for double post, but I updated again!

New features: 2 new secret menu options! :) And if anyone wants the password, PM me. I also removed the d/l latest version link (still have a link to RJB in instructions :)).

Balloony
Star Player!
Star Player!
Posts: 262
Joined: February 26th, 2005, 10:29 am

Post by Balloony » January 4th, 2006, 11:51 am

I think this should be cut off from the Hash code thread so you can present your little proggy in an own topic :)
And 95%, or so, by me. All the tutorial had was the name (Which I may change soon, any suggestions?) and just the picture showing code and how to detect if you won. I got the pic from a google search. I am thinking about making a sound for when you win... The bet, win/lose counter, money system,The thing that says you won, the password stuff, secrets, and the entire file menu and secrets menu, etc. are all by me! Lots added from original, eh?
Gratulations, this is quite a lot for a first project :D
And for the name, what about "Aloshi's Lucky Seven" ;)

Btw, the digit display is now legiblier, although I feel if I spotted a small bug: In first round (when you've just started the prog) you got 15$ basic cash. As soon as you loose and have to start over, you'll get only 10$. Is this meant to be in that way.
"Time flies like an arrow, fruit flies like a banana." -Groucho Marx

Aloshi
Magic Number 400
Magic Number 400
Posts: 401
Joined: September 13th, 2005, 9:34 pm
Location: USA

Post by Aloshi » January 4th, 2006, 11:14 pm

Woops! I changed the value, but didn't change how it resets it! heh... :lol:

Thanks, I'll fix that when I get a chance...

EDIT: OK, updated! Name change, new secrets menu thing, and fixed some other annoying things. :)

Aloshi
Magic Number 400
Magic Number 400
Posts: 401
Joined: September 13th, 2005, 9:34 pm
Location: USA

Post by Aloshi » January 5th, 2006, 11:22 pm

Another new update! Small, only to ver 1.7.2, but an update. Features: You can now use all in bet to bet all your money. And I also fixed some code for all this. :)

Big question to prevent errors: Anyone have an idea how to make it so words other that all will be a statment? So that errors cannot be made by entering words other than all in the box?

Aloshi
Magic Number 400
Magic Number 400
Posts: 401
Joined: September 13th, 2005, 9:34 pm
Location: USA

Post by Aloshi » January 6th, 2006, 11:32 pm

Will wrote:Remind me to post information when I'm less tired, my god I feel like crap at the moment and I can't think
*Reminds Will to post information when he's less tired*

Post Reply