Working with CSV/Tab characters

   Sub OpenFile(sFile As String)

        Dim sLastName As String = ""

        Dim sFirstName As String = ""

        Dim sSite As String = ""

        Dim sSchDOS As String = ""

        Dim sIntv As String = ""

        Dim sTestDate As String = ""

        Dim sTestTime As String = ""

        Dim sDOB As String = ""

        Dim sCase As String = ""

        Dim sSubject As String = ""

        Try

            ToolStripStatusLabel1.Text = "Loading at: " & Now

            Dim tfp As New TextFieldParser(sFile)

            tfp.Delimiters = New String() {vbTab}

            tfp.TextFieldType = FieldType.Delimited

            ListView1.Items.Clear()

            ListView1.BeginUpdate()

            tfp.ReadLine() ' skip header

            While tfp.EndOfData = False

                '"Last.Name"      "First.Name"  "site" "Sch.dos"     "intv" "testdate"    "testtime"       "dob"  "case" "subject"

                Dim fields = tfp.ReadFields()

                sLastName = fields(0)

                sFirstName = fields(1)

                sSite = fields(2)

                sSchDOS = fields(3)

                sIntv = fields(4)

                sTestDate = fields(5)

                sTestTime = fields(6)

                sDOB = fields(7)

                sCase = fields(8)

                sSubject = fields(9)

                Dim lvItem As ListViewItem = ListView1.Items.Add(sLastName)

                lvItem.SubItems.Add(sFirstName)

                lvItem.SubItems.Add(sSite)

                lvItem.SubItems.Add(sSchDOS)

                lvItem.SubItems.Add(sIntv)

                lvItem.SubItems.Add(sTestDate)

                lvItem.SubItems.Add(sTestTime)

                lvItem.SubItems.Add(sDOB)

                lvItem.SubItems.Add(sCase)

                lvItem.SubItems.Add(sSubject)

                '"Last.Name"      "First.Name"  "site" "Sch.dos"     "intv" "testdate"    "testtime"       "dob"  "case" "subject"

                Dim sToolTip As String = String.Format("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9}", sLastName, sFirstName, sSite, sSchDOS, sIntv, sTestDate, sTestTime, sDOB, sCase, sSubject)

                lvItem.ToolTipText = sToolTip

                lvItem.Tag = sSubject

                Console.WriteLine(sToolTip)

            End While

            ListView1.EndUpdate()

            ListView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent)

            ToolStripStatusLabel1.Text = "Refreshed at: " & Now & "    Data Timestamp: " & My.Computer.FileSystem.GetFileInfo(sFile).LastWriteTime.ToShortDateString & " " &

               My.Computer.FileSystem.GetFileInfo(sFile).LastWriteTime.ToShortTimeString

        Catch ex As Exception

            ToolStripStatusLabel1.Text = "Error (OpenFile) at: " & Now & " " & ex.Message.ToString

        End Try

    End Sub

Turn off X, Min and Max in Console windows

Private Declare Auto Function GetConsoleWindow Lib "kernel32.dll" () As IntPtr

    Private Declare Auto Function ShowWindow Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal nCmdShow As Integer) As Boolean

    Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Integer, ByVal revert As Integer) As Long

    Private Declare Function EnableMenuItem Lib "user32" (ByVal menu As Integer, ByVal ideEnableItem As Integer, ByVal enable As Integer) As Integer

    Private Const MF_BYCOMMAND As Integer = &H0

    Public Const SC_CLOSE As Integer = &HF060

    Public Const SC_MINIMIZE As Integer = &HF020

    Public Const SC_MAXIMIZE As Integer = &HF030

    Public Const SC_SIZE As Integer = &HF000

    Friend Declare Function DeleteMenu Lib "user32.dll" (ByVal hMenu As IntPtr, ByVal nPosition As Integer, ByVal wFlags As Integer) As Integer

    Friend Declare Function GetSystemMenu Lib "user32.dll" (hWnd As IntPtr, bRevert As Boolean) As IntPtr

    Dim handle As IntPtr

        handle = Process.GetCurrentProcess.MainWindowHandle ' Get the handle to the console window

        Dim sysMenu As IntPtr

        sysMenu = GetSystemMenu(handle, False) ' Get the handle to the system menu of the console window

        If handle <> IntPtr.Zero Then

            DeleteMenu(sysMenu, SC_CLOSE, MF_BYCOMMAND) ' To prevent user from closing console window

            DeleteMenu(sysMenu, SC_MINIMIZE, MF_BYCOMMAND) 'To prevent user from minimizing console window

            DeleteMenu(sysMenu, SC_MAXIMIZE, MF_BYCOMMAND) 'To prevent user from maximizing console window

            DeleteMenu(sysMenu, SC_SIZE, MF_BYCOMMAND) 'To prevent the use from re-sizing console window

        End If

https://stackoverflow.com/questions/38175206/how-to-prevent-the-console-window-being-resized-in-vb-net


Close Console Window (ie run in Forms mode)

    Private Declare Auto Function GetConsoleWindow Lib "kernel32.dll" () As IntPtr
    Private Declare Auto Function ShowWindow Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal nCmdShow As Integer) As Boolean

    Private Const SW_HIDE As Integer = 0
    Private Const SW_SHOW As Integer = 5

        Dim hWndConsole As IntPtr
        hWndConsole = GetConsoleWindow()
        'ShowWindow(hWndConsole, SW_HIDE)

        Dim bExplorer As Boolean = False
        Dim myPID As Integer = System.Diagnostics.Process.GetCurrentProcess().Id
        Dim myParentProcessName As String = ""
        Dim objWMIService, objProcess, colProcess
        Dim myPPID As Integer

        objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
        colProcess = objWMIService.ExecQuery("Select * from Win32_Process where ProcessID=" & myPID)

        For Each objProcess In colProcess
            myPPID = objProcess.ParentProcessID()
            Try
                myParentProcessName = (Process.GetProcessById(myPPID).ProcessName).ToString()
                If myParentProcessName <> "cmd" Then bExplorer = True
            Catch
                'May have elevated
                bExplorer = True
            End Try
        Next

        If bExplorer Then
            ShowWindow(hWndConsole, SW_HIDE)
            'sMachineName = InputBox("What machine would you like to connect? Leave blank for localhost")
            Dim oForm As New Form1
            oForm.ShowDialog()
        Else
            Console.WriteLine("Hi there")
        End if