?
Solved

Creating online high score table from VB game.

Posted on 2003-11-28
9
Medium Priority
?
1,051 Views
Last Modified: 2012-06-27
Hello,  I have a simple visual basic game that I have made, and I have posted it on a website.  Is there anyway that I can have that visual basic program interact with a text file that is also saved on the website's server.  I would like the game to beable to generate a high score table.  


Thanks for the help.
0
Comment
Question by:Jacamar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
9 Comments
 
LVL 9

Accepted Solution

by:
TooKoolKris earned 252 total points
ID: 9840050
You can turn the webpage into an ASP page and then use some scripting to open an text file for writing and reading.

Sub OpenTextFileTest
   Const ForReading = 1, ForWriting = 2, ForAppending = 8
   Dim fso, f
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.OpenTextFile("c:\testfile.txt", ForWriting, True)
   f.Write "Hello world!"
   f.Close
End Sub

Function ReadTextFileTest
   Const ForReading = 1, ForWriting = 2, ForAppending = 8
   Dim fso, f, Msg
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.OpenTextFile("c:\testfile.txt", ForWriting, True)
   f.Write "Hello world!"
   Set f = fso.OpenTextFile("c:\testfile.txt", ForReading)
   ReadTextFileTest = f.Read(5)
End Function

Function ReadLineTextFile
   Const ForReading = 1, ForWriting = 2
   Dim fso, MyFile
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set MyFile = fso.OpenTextFile("c:\testfile.txt", ForWriting, True)
   MyFile.WriteLine "Hello world!"
   MyFile.WriteLine "The quick brown fox"
   MyFile.Close
   Set MyFile = fso.OpenTextFile("c:\testfile.txt", ForReading)
   ReadLineTextFile = MyFile.ReadLine    ' Returns "Hello world!"
End Function
0
 
LVL 2

Author Comment

by:Jacamar
ID: 9840138
Ok, I don't want to write to a file on the users computer, I want to write to a text file that is on the web server.  I have a file saved as Highscores.txt

I want to interact with that using my VB game.
0
 
LVL 9

Expert Comment

by:TooKoolKris
ID: 9840438
These scripts are for the server side as most processing is done on the server with ASP. You need to do some work of your own if you can't see a vaule in any of those functions for editing and showing text from a text file.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 7

Assisted Solution

by:petoskey-001
petoskey-001 earned 248 total points
ID: 9841517
There are two main ways to do this.

1. Upload and download the Highscores.txt direct from the server using FTP, modift it and put it back when your done.  A simple, insecure and bad way to do things if you have any amount of users on your system, but still doable for small amount of trusted users.  It is the only way possible if your website doesn't allow CGI scripts such as PHP, PERL, Python, etc.  Even then it may not be possible depending on how your web server is setup.  If you want to do that, use the INET control and download the file, modify it and put it back.  Like I said this is not suggested, so I'll concentrate on the other way.

2. Use a CGI script to update and store the high score list.  This is similar to what TooKoolKris is suggesting.  The game would then use HTTP or a database connection to your website database if possible and submit a new high score.  When people view the high score list on your server, the CGI would generate the high score list of the highest top 10 score, or download the generated file.


The CGI would probably accept high score submissions using something like "http://www.mycoolgame.com/cgi-bin/sendmyscore.cgi?playername=Mario&score=12345&verify=ABCDEFG".  

You will want to compute a verification algorithm for your high scores, or it will rather quickly be figured out and people will just enter their own high scores.  The CGI will take verify the score matches the verify code, and if so check if it should be added to the high score list.  You can choose to save all score, or ignore it if it's not in the top 10 and create the Highscores.txt during submission.   I'll let you deal with the database method if you want.  I'm going to assume the CGI generates the HighScores.txt when a new high score is submitted.

I won't get into this how to create the CGI because I don't know what your web server is capable of, or what language your CGI will use.

Here is an example of the Visual Basic end of things.  I use a simple INet Control.  You can add it to your form under the menu Project / Components...   The name is Microsoft Internet Transfer Controls 6.0 (SP4) on my system.  Something like this.

Private Sub Command1_Click()
  Text1.Text = Inet1.OpenURL("http://russell.ryba.net/demos/usamap/?username=Mario&score=123&verify=123", icString)
   'or do into a variable
  strHighscoreList = Inet1.OpenURL("http://russell.ryba.net/demos/usamap/?username=Mario&score=123&verify=123", icString)
End Sub

Then you don't even need to save a temporary file on your game players system.

It's a bit more then you asked for, and a bit less too I guess without the CGI script.  Tell me more about what your server can do and maybe I can help you out with that.
0
 
LVL 7

Expert Comment

by:petoskey-001
ID: 10166920
I think CGI is the only way to go, but at this point I don't know if it still matters.  I would like to see the game though.
0
 
LVL 9

Expert Comment

by:TooKoolKris
ID: 10173307
CGI is going the way of the dinosaur amigo; get with the times :) Besides if this game is in VB there is a good chance the host will be MS as well and ASP.NET blows CGI totally out of the water.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month10 days, 13 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question