Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Open browser and post info to website ?

Posted on 1999-01-11
8
Medium Priority
?
220 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
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

722 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