Few begginers questions
Few begginers questions
Few begginers questions
Few begginers questions
Few begginers questions
Few begginers questions Few begginers questions Few begginers questions Few begginers questions Few begginers questions Few begginers questions Few begginers questions Few begginers questions
Few begginers questions Few begginers questions
Few begginers questions
Go Back  Xtreme Visual Basic Talk > > > Few begginers questions


Reply
 
Thread Tools Display Modes
  #1  
Old 02-15-2007, 04:45 PM
Adrammelech Adrammelech is offline
Freshman
 
Join Date: Feb 2007
Posts: 30
Default Few begginers questions


Hello peeps..Im new to VB.NET and im tryin to make a somewhat simple RPG (like a small version of KOL for those of you who have heard of it) but can't figure out a few things. What im trying to do is-
1. I have a signin form that goes to another form but I dont know how to get it to close once they sign on.
2. I want to know how to save everything in the registry.
Im not good at VB.NET yet so these are the variables I need to have saved. P.S. If i did something wrong tell me plz cause i make a lot of mistakes.
Dim CharName As String
Dim CharLevel As Integer
Dim CharMaxHP As Integer
Dim CharMaxMP As Integer
Dim CharCurrentHP As Integer
Dim CharCurrentMP As Integer
Dim CharMuscle As Integer
Dim CharGold As Integer
Dim CharWeapon As Integer
Dim Pants As Integer
Dim Helmet As Integer
Dim Accessory1 As Integer
Dim Accessory2 As Integer
Dim Accessory3 As Integer

If you know how to solve any of my probs plz help me. Im hopin to finish this project even though I dont know how to do many of the things it will take now but ill build it one step at a time.
Reply With Quote
  #2  
Old 02-15-2007, 10:03 PM
Targe Targe is offline
Contributor
 
Join Date: Nov 2006
Posts: 615
Default

1. Me.Close()
2. Put those variables in a Module file and declare them as Public rather than "Dim."
Reply With Quote
  #3  
Old 02-16-2007, 06:54 AM
Adrammelech Adrammelech is offline
Freshman
 
Join Date: Feb 2007
Posts: 30
Default

Ok thanx, but do you know how I could save all of the variables in the registry. Ive never used the registry and dont have a clue how it works. I found this on a site but dont know if that would work.
Dim regKey As RegistryKey
regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE", True)
regKey.CreateSubKey("MyApp")
regKey.Close()
Reply With Quote
  #4  
Old 02-16-2007, 12:10 PM
Targe Targe is offline
Contributor
 
Join Date: Nov 2006
Posts: 615
Default

I've never worked with the registry but it's probably something like that.

My question is why use the registry? Using the registry isn't really a good method for saving variables, as modifying it can be dangerous if you're not 100% sure what you're doing.

I'd suggest saving variables to a .dat file which can be read upon the form loading. It's simple and just as effective. Only do the registry if you have to.
Reply With Quote
  #5  
Old 02-16-2007, 04:39 PM
Adrammelech Adrammelech is offline
Freshman
 
Join Date: Feb 2007
Posts: 30
Default

Ok if i was to save all of my variables in a .dat file, how would I do it. I dont have much experience with programing so I cant do much now. And another question. How would I do a created a character form. Would I just have it save it to a .dat file?
Reply With Quote
  #6  
Old 02-16-2007, 07:25 PM
Targe Targe is offline
Contributor
 
Join Date: Nov 2006
Posts: 615
Default

What do you mean by created character form?

http://www.freevbcode.com/ShowCode.Asp?ID=4492

That link should help ya on saving files...if you don't want the user being able to access the file and manipulate it, I'd use the registry...or perhaps make an encryption key in the program for the values being saved to the file.
Reply With Quote
  #7  
Old 02-17-2007, 10:23 AM
Adrammelech Adrammelech is offline
Freshman
 
Join Date: Feb 2007
Posts: 30
Default

.dat file would work but how would I save and read variables in it? And by character form, I mean you type a username and password and then you can use it to sign in.
Reply With Quote
  #8  
Old 02-17-2007, 02:32 PM
Targe Targe is offline
Contributor
 
Join Date: Nov 2006
Posts: 615
Default

During the saving process you write your variable amounts to the file. When you read it back, you read those variable amounts in to the variables again.

For username and password you may want to look into something more secure. A dat file can easily be read by anyone, and since usernames/passwords might be saved to that file, again, I recommend encryption.
Reply With Quote
  #9  
Old 02-17-2007, 07:36 PM
Adrammelech Adrammelech is offline
Freshman
 
Join Date: Feb 2007
Posts: 30
Default

Im not worried about encryting it now. What would the code look like saving and loading in a .dat file. Would it look like the saving game thread?
Reply With Quote
  #10  
Old 02-18-2007, 12:58 PM
Targe Targe is offline
Contributor
 
Join Date: Nov 2006
Posts: 615
Default

Yes. And I'm not 100% sure on this (since I haven't tried), but I'd guess the saving process is similar to C++ where you can create a text based file with any extension you want...txt, dat, whatever. Whatever it's saved to, you just read it back as text. Might look into binary files but I've never tried in VB.
Reply With Quote
  #11  
Old 02-18-2007, 08:00 PM
Adrammelech Adrammelech is offline
Freshman
 
Join Date: Feb 2007
Posts: 30
Default

Is there a way to have the game save as soon as someone exits so they dont have a choice to save?
Reply With Quote
  #12  
Old 02-18-2007, 08:40 PM
Targe Targe is offline
Contributor
 
Join Date: Nov 2006
Posts: 615
Default

Yes, check the closing events.
Reply With Quote
  #13  
Old 02-19-2007, 08:35 PM
Adrammelech Adrammelech is offline
Freshman
 
Join Date: Feb 2007
Posts: 30
Default

Could it save when they exit even if they click on the "X" in the corner? And I still havent figured out how to save or load variables cause like i said earlier, Im not very good at VB.NET now.
Reply With Quote
  #14  
Old 02-19-2007, 09:17 PM
Targe Targe is offline
Contributor
 
Join Date: Nov 2006
Posts: 615
Default

Yes, the X is closing the form and activates the closing event the same as any regular stlye of closing, but I don't think Ctrl+Alt+Del would activate it.

I hate to sound unhelpful (is that a word?) but a good resource would be to buy any old VB book. I have 3 different ones and all have solid coding on saving/loading files. Of course this forum can provide you the same material...just suggesting it.

You save the variables just as a string to the text file. So let's say you have Health (70 pts) and magic (50 pts) of the player you want to save for an RPG, you might save it to the file like so:

"70, 50"

When reading it back you have the comma as your delimiter. A space could work too...blah...I know I'm explaining all this poorly so I'll shutup now...but trust me, it's a lot easier than I'm making it sound. Have you found code on saving/loading? If not I'll provide you some.
Reply With Quote
  #15  
Old 02-20-2007, 07:02 AM
Adrammelech Adrammelech is offline
Freshman
 
Join Date: Feb 2007
Posts: 30
Default

I have a book but it doesn't explain much. It is just a begginers book and it basically just explains what all the tools in the toolbar do. They dont mention saving/loading any in it.
Thanx for the help.

Last edited by Adrammelech; 02-20-2007 at 07:32 AM.
Reply With Quote
  #16  
Old 02-20-2007, 08:40 AM
Sirstrafe Sirstrafe is offline
Newcomer
 
Join Date: Sep 2004
Posts: 7
Default

I think Targe was on to something. If your list of variables don't change, write out everything in one line in a comma separated string.

example: billybob, 5,70,50,70,50,10,1500,short sword,leather pants,iron helmet,empty,empty,empty.

Read in the single line of text and parse the string:
Dim charstats As String() = filereader.ReadLine.Split(ControlChars.Comma)

This is not perfect by any means but it might get you where you need to go. This is just a suggestion. There are many other ways to do this, I would use XML or something similiar.
__________________
It's not if you are faster than the hungry bear, its' the fact that you are faster than your friends who are also running from the hungry bear.
Reply With Quote
  #17  
Old 02-22-2007, 02:37 PM
Adrammelech Adrammelech is offline
Freshman
 
Join Date: Feb 2007
Posts: 30
Default

Sorry yall but i still aint completely understanding this.
This is the complete thing Im trying to accomplish
1.There is a create a character form that saves a name and password as a string. I want it to save it so I can create as many Ids as i want and still be able to sign in with any of them.
2. I want it so when I sign in, It loads all the stats and when I exit, it saves all the stats in a text file.

Sorry if its frusterating trying to teach me this.
Reply With Quote
  #18  
Old 02-22-2007, 03:27 PM
Targe Targe is offline
Contributor
 
Join Date: Nov 2006
Posts: 615
Default

Hmm...rethinking this for your problem, I'd recommend using a database instead. Look into ADO.NET and it will easily do the things you want.
Reply With Quote
  #19  
Old 02-22-2007, 03:29 PM
Targe Targe is offline
Contributor
 
Join Date: Nov 2006
Posts: 615
Default

Or rethinking this again...just save the different users to different lines and have the program check each line for the user who is signing in. If the user exists you can read the rest of the line for the information, otherwise, it will add the user to the next available line.
Reply With Quote
  #20  
Old 02-22-2007, 07:14 PM
Adrammelech Adrammelech is offline
Freshman
 
Join Date: Feb 2007
Posts: 30
Default

I dont know how to save it to a text file. Would it be like use WriteLine to put it into a text file and how would i get it to save it as a different line for each username?
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Few begginers questions
Few begginers questions
Few begginers questions Few begginers questions
Few begginers questions
Few begginers questions
Few begginers questions Few begginers questions Few begginers questions Few begginers questions Few begginers questions Few begginers questions Few begginers questions
Few begginers questions
Few begginers questions
 
Few begginers questions
Few begginers questions
 
-->