Creating online high score table from VB game.

Posted on 2003-11-28
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.
Question by:Jacamar
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

Accepted Solution

TooKoolKris earned 63 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!"
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"
   Set MyFile = fso.OpenTextFile("c:\testfile.txt", ForReading)
   ReadLineTextFile = MyFile.ReadLine    ' Returns "Hello world!"
End Function

Author Comment

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.

Expert Comment

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.
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.


Assisted Solution

petoskey-001 earned 62 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 "".  

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("", icString)
   'or do into a variable
  strHighscoreList = Inet1.OpenURL("", 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.

Expert Comment

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.

Expert Comment

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.

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

705 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