Hi,
I want to write data to a txt file using vb 2012 structure. I have a form with 3 textbox, one for Name, one for LastName and one for Age. when a run the program i'm having error on the FILEPUT line. And when a open the file (prueba.txt) is empty. Please help , any good advise on it.
here is my code:
Imports System.IO
Public Class Form1
'Create a record type. The name of the record
'structure is given as “Person”.
Public Structure Person
Public Name As String
Public LastName As String
Public Age As String
End Structure
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim client As New Person
Dim RecordNumber As Integer
With client
.Name = TextBox1.Text
.LastName = TextBox2.Text
.Age = TextBox3.Text
End With
FileOpen(1, My.Computer.FileSystem.SpecialDirectories.MyDocuments & "prueba.txt", OpenMode.Random, OpenAccess.Write, OpenShare.LockWrite, Len(client))
RecordNumber = 1
FilePut(1, client, RecordNumber)
FileClose(1)
End Sub
I want to write data to a txt file using vb 2012 structure. I have a form with 3 textbox, one for Name, one for LastName and one for Age. when a run the program i'm having error on the FILEPUT line. And when a open the file (prueba.txt) is empty. Please help , any good advise on it.
here is my code:
Imports System.IO
Public Class Form1
'Create a record type. The name of the record
'structure is given as “Person”.
Public Structure Person
Public Name As String
Public LastName As String
Public Age As String
End Structure
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim client As New Person
Dim RecordNumber As Integer
With client
.Name = TextBox1.Text
.LastName = TextBox2.Text
.Age = TextBox3.Text
End With
FileOpen(1, My.Computer.FileSystem.SpecialDirectories.MyDocuments & "prueba.txt", OpenMode.Random, OpenAccess.Write, OpenShare.LockWrite, Len(client))
RecordNumber = 1
FilePut(1, client, RecordNumber)
FileClose(1)
End Sub