1 Replies - 731 Views - Last Post: 28 October 2012 - 10:53 AM Rate Topic: -----

#1 small_chick  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 19-July 12

Put & Get methods - VB6 ?

Posted 28 October 2012 - 08:58 AM

I've read some code as follow:
If CommonDialog1.FileName <> "" Then
        Open CommonDialog1.FileName For Binary As #1
        Put #1, , data
        Close #1
    End If

and next:
If CommonDialog1.FileName <> "" Then
        Open CommonDialog1.FileName For Binary As #2
        Get #2, , data
        Close #2
        For i = 0 To 10
            Text1.Text = Text1.Text & data(i)
            MSComm1.Output = Chr(data(i))
        Next
            MSComm1.Output = vbCrLf
            Timer1.Enabled = True
    End If

I haven't understood "Get & Put" methods used here! I mean their structure ! I've done some search on Google but there's no clear result ! therefore, I hope someone can help me ! Waiting for your help! :bigsmile:

Is This A Good Question/Topic? 0
  • +

Replies To: Put & Get methods - VB6 ?

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4316
  • View blog
  • Posts: 12,096
  • Joined: 18-April 07

Re: Put & Get methods - VB6 ?

Posted 28 October 2012 - 10:53 AM

Put and Get are functions that Write or Read from a file opened in binary mode. So for instance, in the examples you show they open up the file specified in the CommonDialog in Binary mode and are given file numbers 1 and 2. You then use these file numbers to specify the file stream.

When you do something like Put #1, , data you are saying "Write to file #1, starting at the position where the last Put/Get statement left off, the content in the variable 'data'".

Get is the opposite, Get #2, , data is saying "Read data from file number 2, starting at the position where the last Put/Get statement left off, and place that read content into the variable called 'data'".

They are just read/write methods for files opened in binary mode. Hopefully that answers the question. :)

This post has been edited by Martyr2: 28 October 2012 - 10:54 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1