Imports System.IO Public Class uploadMcSeq Private Sub uploadMcSeq_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.MdiParent = mainForm Control.CheckForIllegalCrossThreadCalls = False Me.Top = 5 Me.Left = 5 End Sub Private Function browseFile() As String Dim stFileName As String = String.Empty Dim openFileDialog1 As New OpenFileDialog openFileDialog1.InitialDirectory = "C:\" openFileDialog1.Title = "Open Machine Sequence Text File" openFileDialog1.Filter = "Text files (*.txt)|*.txt" openFileDialog1.FilterIndex = 1 openFileDialog1.RestoreDirectory = True If openFileDialog1.ShowDialog() = DialogResult.OK Then stFileName = openFileDialog1.FileName End If Return stFileName End Function Private Sub btn_browse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_browse.Click txtFName.Text = browseFile() End Sub Private Sub btn_cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_cancel.Click Me.Close() End Sub Private Sub btn_upload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_upload.Click getfilecontents(txtFName.Text) End Sub Private Sub getfilecontents(ByVal fullpath As String) Dim strcontent As String = String.Empty Dim line() As String Dim objreader As StreamReader Dim seq As New Sequence Dim addHeader As Boolean = False Dim nos As String = String.Empty Try objreader = New StreamReader(fullpath) strcontent = objreader.ReadLine 'disregard header strcontent = objreader.ReadLine While strcontent <> "" line = Split(strcontent, vbTab) seq.account = line(0) seq.revision = line(2) seq.line = line(3) seq.machine = line(4) seq.model = line(5) seq.pcbside = line(6) seq.partno = line(7) seq.modules = line(8) seq.feeder = line(9) seq.feederType = line(10) seq.topsdloc = line(11) seq.fsbsqty = line(12) seq.desc1 = line(13) seq.desc2 = line(14) seq.topmark = line(15) seq.remarks = line(16) seq.prepby = loginForm.username seq.checkby = String.Empty seq.chkdate = String.Empty seq.updtime = DateTime.Now If nos.Length = 0 Then nos = seq.generateNo("B9") End If seq.sequenceno = nos If addHeader = False Then If seq.addHeader() Then addHeader = True Else MessageBox.Show("An error was encountered.", "Upload Sequence", MessageBoxButtons.OK, MessageBoxIcon.Error) Exit Sub End If End If If Not seq.addDetail() Then MessageBox.Show("An error was encountered.", "Upload Sequence", MessageBoxButtons.OK, MessageBoxIcon.Error) Exit Sub End If strcontent = objreader.ReadLine End While objreader.Close() MessageBox.Show("Successfully uploaded!") txtFName.Text = String.Empty mcSeqForm.getSequence() Catch ex As Exception End Try End Sub End Class