Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Open browser and post info to website ?

Posted on 1999-01-11
8
Medium Priority
?
225 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
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
Technology Partners: 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 480 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…
Suggested Courses

824 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