Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Creating online high score table from VB game.

Posted on 2003-11-28
Medium Priority
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 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!"
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.

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


Assisted Solution

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.

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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

636 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