Solved

Open browser and post info to website ?

Posted on 1999-01-11
8
197 Views
Last Modified: 2010-05-03
I'm writing a strategy game in VB 5.0. The game calculates a score and I'd like to have "high scores" posted on my website. I'd like for the game to offer the option to post a high score in a small database table (or such) on the website. The option should preferably open the default browser (if necessary), link to the proper site, then add a record into a table, which sorts by high score, then nickname. How do you open the default browser, link to a site, then add a record in VB 5.0? I would use an Access table or am open to an alternative method. This solution needs to work with Win95 in addition to Win98.
0
Comment
Question by:tyroneb
8 Comments
 

Expert Comment

by:edunc
Comment Utility
use an ftp control to upload a preset webpage w/ the scores added to it w/ VB.  then use this code to open a browser to the page:
retVal = shell("start www.yourpage.com/scores.html")
0
 

Author Comment

by:tyroneb
Comment Utility
Almost there. Thanks edunc, but I need more info. I have a "basic" installation of VB 5.0 Professional and in the "Components" box, I did not see an "FTP control" listed. Do I get it from somewhere or could I use the Inet control? I think I could build a "preset web page", but will the website "accumulate" different records from "all over" from possibly hundreds of clients? Also, the command: retVal = shell("start www.yourpage.com/scores.html") seems to be doing something processing-wise, but doesn't open my browser. I've seen this command tonight on this site and I'm wondering if it only works for Win98. I guess I need to have my hand held a little bit more :-).
0
 
LVL 4

Expert Comment

by:chabaud
Comment Utility
You can easily post data to the web with the Internet Transfer Control (method Excecute).

I think you main pb will be to collect the data on the web site (in a database ?). Can you create cgi program or asp on the web server (are your granted to ?).

If not you could only receive data through mail, putting starting the url with mailto:

0
 

Author Comment

by:tyroneb
Comment Utility
Since I'm a database programmer by nature, the first solution to come to mind for a file that accumulates records or lines is a database. I'm open to other options, but would need to know how to do it.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 4

Expert Comment

by:chabaud
Comment Utility
The main first question is: Where is your web site ? on internet or on intranet.
0
 

Author Comment

by:tyroneb
Comment Utility
It is an internet-only application with a web-host that supports all the bells and whistles: asp, front-page extensions, cgi-bin, etc. (all the things that I haven't worked with much :-) )
0
 

Author Comment

by:tyroneb
Comment Utility
Adjusted points to 120
0
 
LVL 10

Accepted Solution

by:
MasseyM earned 120 total points
Comment Utility
Check out this answer...

Dim success As Integer
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
'------------------------------------------------------------------
 
'This elow shold be attached to a button command
Private Sub cmdWeb_Click()
Dim success As Integer
Site = "http://yoursitehere.com/postscore.asp?score=" & theirScore & "?nickname=" & Nickname
End If
success% = ShellToBrowser(Me, Site, 0)
End Sub

 
Function ShellToBrowser%(Frm As Form, ByVal URL$, ByVal WindowStyle%)
     
    Dim api%
        api% = ShellExecute(Frm.hwnd, "open", URL$, "", App.Path, WindowStyle%)
 
    'Check return value
    If api% < 31 Then
        'error code - see api help for more info
        MsgBox App.Title & " had a problem running your web browser.  You should check that your browser is correctly installed.(Error" & Format$(api%) & ")", 48, "Browser Unavailable"
        ShellToBrowser% = False
    ElseIf api% = 32 Then
        'no file association
        MsgBox App.Title & " could not find a file association for " & URL$ & " on your system. You should check that your browser is correctly installed and associated with this type of file.", 48, "Browser Unavailable"
        ShellToBrowser% = False
    Else
        'It worked!
        ShellToBrowser% = True
    End If
     
End Function
 

This will launch the browser and open the page called PostScore.asp.  It will ass the parameters called nickname and score.

In the ASP page, you would have something like this:

postscore.asp
-----------------
<!-- #Include File="TDSN.asp" -->
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open sDSN
Set RS = Server.CreateObject("ADODB.Recordset")
SQL = "SELECT * FROM Scores;"
RS.Open SQL, Conn, 3, 3
RS.AddNew
RS("Score") = Request.QueryString("Score")
RS("NickName") = Request.QueryString("nickname")
RS.Update
RS.Close
Conn.Close
Set RS = nothing
Set Conn = nothing
%>
<BODY>
YOUR HTML CODE HERE.
Thanks for your score.  It is posted in the database.  Click <A HREF="viewscores.asp">here</A> to view the top scores.


TDSN.ASP
-------------
<%
  sDB   = "databasename.mdb"
  sScriptDir = "virtual/path/to/database"
  sPath = Server.MapPath(sScriptDir) + "\"
  sDSN = "filedsn=" & sPath & "Score.dsn;DefaultDir=" & sPath & ";DBQ=" & sPath & sDB & ";"
%>

Score.dsn
--------------
[ODBC]
DRIVER=Microsoft Access Driver (*.mdb)
UID=admin
UserCommitSync=Yes
Threads=3
SafeTransactions=0
PageTimeout=5
MaxScanRows=8
MaxBufferSize=512
ImplicitCommitSync=Yes
FIL=MS Access
DriverId=25

That should do it.  YOu will need an Access database that has a table called "SCORES" with a field called "NICKNAME" and another called "SCORE".  Create the files t hat I have listed above.  Fix the places you need to.  Then you are off.

YOu can email me at masseym@hotmail.com if you need more help.  Have fun and let me know where this site is so I can see it in action.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now