Solved

Open browser and post info to website ?

Posted on 1999-01-11
8
216 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
[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
8 Comments
 

Expert Comment

by:edunc
ID: 1455578
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
ID: 1455579
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
ID: 1455580
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
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!

 

Author Comment

by:tyroneb
ID: 1455581
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
 
LVL 4

Expert Comment

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

Author Comment

by:tyroneb
ID: 1455583
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
ID: 1455584
Adjusted points to 120
0
 
LVL 10

Accepted Solution

by:
MasseyM earned 120 total points
ID: 1455585
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

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…
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…
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…
Suggested Courses
Course of the Month3 days, 23 hours left to enroll

630 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