Option Strict Off Option Explicit On Friend Class Form1 Inherits System.Windows.Forms.Form Dim CommData As Integer Dim Connect As Short ' Nije spojen = 0 ' Spojen = 1 Dim Result As Short Private Declare Function Online_ESC_Y_BYTE Lib "C:\UNI_TRANS\OnlineDll.Dll" Alias "Online_ESC_Y" (ByVal CommData As Integer, ByVal tAdd As Short, ByRef bDat As Byte, ByRef bLen As Byte) As Short Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load CommData = Online_Create() Connect = 0 If CommData <> 0 Then Result = Online_SetupEx(CommData, 18, Asc("7"), Asc("1"), Asc("N")) ' Result = 1 End If End Sub Private Sub Form1_FormClosed(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed If CommData <> 0 Then Call Online_Destroy(CommData) CommData = 0 Connect = 0 End If End Sub Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click 'Spajaj If (CommData <> 0) And (Connect = 0) Then Connect = Online_Connect(CommData) End If MsgBox(Connect) End Sub Private Sub Command2_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command2.Click 'odspoji If (CommData <> 0) And (Connect = 1) Then Call Online_Disconnect(CommData) Connect = 0 End If MsgBox(Connect) End Sub Private Sub Command3_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command3.Click 'Prebaci Dim NameStr As String Dim FileLen_Renamed As Integer Dim TextAsc(120) As Byte Dim TextLen As Byte Dim Count As Byte If (CommData = 0) Or (Connect = 0) Then Exit Sub NameStr = "C:\UNI_TRANS\COLLECT.TXT" 'C:\UNI_TRANS\ FileOpen(1, NameStr, OpenMode.Append, OpenAccess.Default, OpenShare.Default, 1) 'Suppose File Exists 'Suppose FileLen>0 Result = Online_ESC_L(CommData, Asc("A"), "COLLECT.TXT", 10) 'Suppose Result = 1 FileLen_Renamed = LOF(1) OK: TextLen = 120 If TextLen > FileLen_Renamed Then TextLen = FileLen_Renamed For Count = 1 To TextLen FileGet(1, TextAsc(Count - 1)) Next Count Result = Online_ESC_Y_BYTE(CommData, Asc("A"), TextAsc(0), TextLen) 'Suppose Result = CmdACK (4) Call Online_ACK(CommData, Asc("A")) FileLen_Renamed = FileLen_Renamed - TextLen If FileLen_Renamed > 0 Then GoTo OK Result = Online_ESC_Z(CommData, Asc("A")) 'Suppose Result = CmdACK (4) Call Online_ACK(CommData, Asc("A")) FileClose(1) MsgBox("File Download", , "COLLECT.TXT") End Sub End Class