Help in Random Accessing a file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ksrao84
    New Member
    • Feb 2007
    • 1

    #1

    Help in Random Accessing a file

    hi!
    i am new to VB. i wanted to store the array of data(X,Y) ,a structure using random access.and also i wanted a header for the file.

    So i have store two different structures in the same file .i had opened the file with out any length being specified.i had written the header and continued writing the array of data. there is no problem. as of now i am able to read back the data(in sequence,first header fallowed by data).


    will there be any problem?
    is it going to work always?

    please give me some insight regarding this issue.

    with regards
    K.S.Rao
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Greetings and salutations!

    If you would not mind posting some of your work here, it'd be easier to help you. In the mean time, see what you can gather from the following. A computer guessing game I created from college, 1 form, 1 module, random numbers picked by your system, user/you must guess a high number and low number, pretty preliminary and simple to crack. Hope this helps you get started:

    Form code, please forgive the lack of comments included today, sleepy as of now:

    Code:
    Dim lowerbound As Integer
      Dim upperbound As Integer
    
    Private Sub connand1_click()
        Form1.Label1 = Int(10 * Rnd) + 1
    End Sub
    
    
    
    
    Private Sub Command1_Click()
    
    Module1.play_game
    
    End Sub
    Private Sub form_load()
        Randomize
        lowerbound = Int(InputBox("enter the lower number"))
        upperbound = Int(InputBox("enterput the higher number"))
            
        computer_num = Int((((upperbound - lowerbound + 1) * Rnd) + lowerbound))
        
    End Sub

    Module code:

    [CODE]

    Public computer_num As Integer
    Dim x As Integer


    Public Sub play_game()

    Dim use_num As Integer
    x = 1
    Do While x < 6

    use_num = Int(InputBox("E nter your guess please!"))
    If use_num = computer_num Then
    Form1.Label1.Ca ption = "you win"

    x = 7

    ElseIf use_num < computer_num Then
    Form1.Label1.Ca ption = "you are to low try again"

    ElseIf use_num > computer_num Then
    Form1.Label1.Ca ption = "your to high try again"

    Else: MsgBox ("error fix me")
    End If

    x = x + 1
    Loop

    End Sub

    [CODE]

    Will post comment, if needed, late here, will check back with you in case you need further clarification.

    Good luck!

    Dököll

    Comment

    Working...