Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Unanswered: Play Simon in VB

    Here's a Simon game I designed for my niece in VB. It's actually somewhat fun so any feedback would be great since it's my 4th vb game/vb project. I'll send the code in the next thread or if I get any requests from anybody to see it. I would still like to know though how I could keep the high scores in a database table as part of the executable project. Everything I've read is that you either need to use MSAccess tables or SQL Server/MySQL. I would like to make a true stand-alone where someone doesn't need any database program such as MSAccess. I'm also learning that if I were to store the data in MSAccess tables and attach it to the *.exe, if I then move the MSAccess file somewhere else, the vb *.exe file will blow up. Any help would be appreciated (i.e. Can I use Foxpro tables to make it all into one exe file without someone having to have foxpro on their machine?)
    Attached Files Attached Files
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi Paul

    Any reason you can't pop the results in a text file? We aren't talking a multi table relational db here just one table with a few columns yes?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Text file

    I'll give it a shot! Thanks Pootle Flump! Since I'm rather new at designing in visual basic, (I usually design in MSAccess), there are many things I've yet to learn. Thank you very much for steering me at something to look into!
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    No probs

    Dunno how good this is but here is some code I use to read and write error info to a txt file. Although it loops through each row to find the relevent record (this was the only way I could see how to identify the last record....) it is blisteringly fast so it won't hold up your app (I tested writing and reading 1 million rows and the time taken was barely perceptible).
    Code:
    '########################### BEGIN Writing errors to error log ###########################
    'Public function to write the error to the log. Returns 1 if successful
    Public Function fWriteErrorLog(ProcName As String, ModName As String, Optional BespokeErrorDesc As String) As Byte
     
        Dim i As Integer
        Dim ErrNo As Long
        Dim ErrDesc As String
        Dim ErrSource As String
     
        ErrNo = Err.Number
        ErrDesc = Err.Description
        ErrSource = Err.Source
     
    On Error GoTo fWriteErrorLog_Error
    'fGetNextLogNo - private function that returns the next sequential log number
        i = fGetNextLogNo
     
    'Open the error log for adding an error record. fGetLogPath is a private function returning
    'the error log file path
        Open fGetLogPath For Append Shared As #1
    'The error details and procedure\ module names and bespoke error description are added
        Write #1, i, Now(), fOSUserName, ErrNo, ErrDesc, ErrSource, ProcName, ModName, BespokeErrorDesc
    'File is closed
        Close #1
    'Success returned
        fWriteErrorLog = 1
     
    'Clean up
        Err.Clear
        Exit Function
     
    fWriteErrorLog_Error:
     
    'Return failure. Nothing more returned regarding errors as nothing more can be done.
        fWriteErrorLog = 0
        Err.Clear
     
    End Function
     
    'fGetNextLogNo - private function that returns the next sequential log number
    Private Function fGetNextLogNo() As Integer
    On Error GoTo fGetNextLogNo_Error
     
        Dim i As Integer
        Dim strField As String
        Dim datField As Date
        Dim lngErrNo As Long
     
    'Open the log file for reading.fGetLogPath is a private function returning the error log file path
        Open fGetLogPath For Input Shared As #1
     
    'Loop through the entries to the end
        Do While Not EOF(1)
     
            'Attribute the sequential log number to i
            Input #1, i, strField, strField, lngErrNo, strField, strField, strField, strField, strField
     
        Loop
     
    'Once the loop has completed, i = the last log number. So, the return is i+1
        fGetNextLogNo = i + 1
     
    'Clean up
        Close #1
     
        Exit Function
     
    fGetNextLogNo_Error:
    'If it errors, make the number return 9999 & clean up
        fGetNextLogNo = 9999
     
        Close #1
     
    End Function
     
    'fGetLogPath is a private function returning the error log file path
    Private Function fGetLogPath() As String
     
    'Derive the log path from the data path
        fGetLogPath = Replace(Replace(fPopulatestrDataPath, ".mdb", ".log"), "_data", "_error")
     
    End Function
    '########################### END Writing errors to error log ###########################
    You can also do this with the fso textstream object but I read a few things that suggested it was much slower than this.

    HTH
    Last edited by pootle flump; 07-10-06 at 07:57.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Thanks for the example

    Awesome again Pootle Flump! I really, really appreciate the help - especially the example!! Now if I could only convince my new work place (which I just started at) that VB/VBA and SQL Server/Oracle would be of great help to the company. We currently use Progress/4GL and an application written by Infor (written in 4GL). I'm doing these programs on the side at home so I can keep up with technology and not lose touch with Microsoft as I feel as though I've taken a step backwards here working with Progress and 4GL (in a character-based environment and no GUI). Since this is the Visual Basic threads I think I can safely say that I detest Progress and 4GL!! If any VB'ers out there want to chime in, please let me know your thoughts as I'm often told here that "Progress and 4GL can do anything SQL Server and vb/vba can do - why change." You know - the learn it or leave syndrome.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  6. #6
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    No probs.

    I know nothing about either. You could try just asking for a comparison of SQL Server and Progress in the SQL Server forum. A lot of the posters in that forum have 3 decades of db experience so they are likely to have something for you.
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •