codeorder 197 Nearly a Posting Virtuoso
Private Sub MonthCalendar1_DateChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MonthCalendar1.DateChanged
        '// if you have the months from January to December in your ComboBox, then this should work.
        ComboBox1.SelectedIndex = MonthCalendar1.SelectionStart.Month - 1
    End Sub

You might need to set the "MaxSelectionCount" to 1 in the MonthCalendar's Properties.

codeorder 197 Nearly a Posting Virtuoso

You will also need a Timer to keep up with the Time.
As for the clock it's self, you will probably have to draw it, possibly inside a Panel.

codeorder 197 Nearly a Posting Virtuoso
TextBox1 = ""

The above line will cause this error: Value of type 'String' cannot be converted to 'System.Windows.Forms.TextBox'. Can easily be fixed by setting the .Text of the TextBox as the String, and not the TextBox it's self.

TextBox1.Text = ""

Without your code that generates the error, it is difficult for someone to exactly recreate it.

codeorder 197 Nearly a Posting Virtuoso

See if this helps.

Public Class Form1

    Private Sub TxbPostcode_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TxbPostcode.LostFocus
        Dim txtValidator As New txtValidation
        If Not txtValidator.validateTextBox(TxbPostcode) = True Then
            MsgBox("Postcode not OK." & vbNewLine & " Needs to have 2 letters and 4 numbers seperated by a space.: EB 3698", MsgBoxStyle.Critical)
            TxbPostcode.Clear() : TxbPostcode.Select()
        End If
    End Sub
End Class

Public Class txtValidation
    Public Function validateTextBox(ByVal selectedTextBoxToValidate As TextBox) As Boolean
        With selectedTextBoxToValidate
            If .Text = "" Then Return False '// if no text.
            If Not .TextLength = 7 Then Return False '// if not correct length.
            If Not Char.IsLetter(.Text(0)) OrElse Not Char.IsLetter(.Text(1)) Then Return False '// if not first 2 char. are letters.
            If Not .Text(2) = " " Then Return False '// if not 3rd char. is space.
            '// if not last 4 char. are #'s.
            If Not Char.IsDigit(.Text(3)) OrElse Not Char.IsDigit(.Text(4)) OrElse Not Char.IsDigit(.Text(5)) OrElse Not Char.IsDigit(.Text(6)) Then Return False
            '// if not less/greater than amount set.
            If CInt(.Text.Substring(3)) < 1000 OrElse CInt(.Text.Substring(3)) > 9999 Then Return False
        End With
        Return True '// if all cleared.
    End Function
End Class
codeorder 197 Nearly a Posting Virtuoso

>>I kinda forgot to ask if there was a way to add up all the totals for a grand total, to see how much profit was made for that one day, is that possible?

Without items in the ListView, you cannot get a "how much profit was made for that one day", now can you?

The grand total code should be placed in a Button.Click or can even be added to the same Sub that adds items to the ListView. If the same Sub, I would remove the MsgBox and have a Label instead. Also, make sure it is right after the add items code and not before.

codeorder 197 Nearly a Posting Virtuoso

To save and load a ListView with columns, view this thread.

To get a total for the day, see if this helps.

With ListView1
            If Not .Items.Count = 0 Then '// check if items in ListView.
                Dim dTotal As Double = 0
                For Each itm As ListViewItem In .Items '// loop thru items.
                    '// check if column 4 item has a value and add it to your total.
                    If Not itm.SubItems(3).Text = "" Then dTotal += CDbl(itm.SubItems(3).Text)
                Next
                MsgBox(dTotal.ToString("c")) '// display result.
            End If
        End With

Making a "repeating program", whatever that is, add a Timer, enable it on Form1_Load and place a MsgBox in the Timer's_Tick event.

codeorder 197 Nearly a Posting Virtuoso

Before you can run the provided code, you will need a File which loads all UPCs and Prices from it to 2 ArrayLists.
I saved mine to: Private myUPCsAndPricesFile As String = "C:\myUPCsAndPricesFile.txt" .

The file content should contain both UPC and individual Price for each item, and should be separated by a single space (" ") .

0921115150 3.50
2221001501 17.25
6652300415 3.25
2221001501 20.00
0255541028 1.85
0921115150 32.56
2221001501 25.26

As for what makes the app. tick, see if this helps.
1 ListView, 2 TextBoxes(TextBox1=UPC, TextBox2=Quantity), 1 Button

Public Class Form1
    Private myUPCsAndPricesFile As String = "C:\myUPCsAndPricesFile.txt"
    Private arlUPC, arlPrices As New ArrayList '// store UPCs and Prices in 2 ArrayLists.

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        With ListView1 '// customize ListView.
            .Columns.Add("UPC", 100) : .Columns.Add("Quantity", 100) : .Columns.Add("Price", 100) : .Columns.Add("Total", 100)
            .View = View.Details : .FullRowSelect = True
        End With
        If IO.File.Exists(myUPCsAndPricesFile) Then '// check if File.Exists.
            For Each fileLine As String In IO.File.ReadAllLines(myUPCsAndPricesFile) '// loop thru all file lines.
                If Not fileLine = "" Then '// make sure there is a value in file line.
                    arlUPC.Add(fileLine.Split(" "c).GetValue(0)) '// .Split file line by the " "(space), and add first value to the UPC ArrayList.
                    arlPrices.Add(fileLine.Split(" "c).GetValue(1)) '// add second value to the Prices ArrayList.
                End If
            Next
        Else '// if File does not Exist.
            MsgBox("This application will not run without the system file:" & vbNewLine & myUPCsAndPricesFile, MsgBoxStyle.Critical)
            Application.Exit()
        End If
        Button1.Text = "Add New"
    End …
codeorder 197 Nearly a Posting Virtuoso

Pass the ex.Message as a Parameter.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim x As String = ""
        Try
            x = CStr(CInt(x) + 1)
        Catch ex As Exception
            getErrorMessage(ex.Message)
        End Try
    End Sub
    Private Sub getErrorMessage(ByVal theReasonForTheError As String)
        MsgBox("Your error message is: " & vbNewLine & theReasonForTheError, MsgBoxStyle.Critical)
    End Sub
End Class

Application.Exit will close the entire application.
Me.Close will close the current Form.
Depending if set for "When last form closes" or "When startup form closes" in your project's Properties/Application tab, it will respond differently for Me.Close .

msqueen082 commented: thank you this worked great.. +1
codeorder 197 Nearly a Posting Virtuoso

Also, check out this post.

codeorder 197 Nearly a Posting Virtuoso

This was not tested, but should work.

Dim strTemp As String = ""
        Dim sql As String = "SELECT * FROM DETAILPERIKSA ORDER BY IDPERIKSA DESC"
        cmd = New OleDbCommand(sql, Conn)
        dtReader = cmd.ExecuteReader
        If dtReader.Read Then
            strTemp = dtReader.Item("IDPERIKSA").ToString
            strTemp = strTemp.Substring(strTemp.LastIndexOf("/") + 1) '// get all char.s after the last "/".
        Else
            TxtDETAILTRANS.Text = "MR/IR/001"
            Exit Sub
        End If
        'MsgBox(strTemp)
        TxtDETAILTRANS.Text = "MR/IR/" & CInt(CInt(strTemp) + 1).ToString("000") '// increment # +1, and Format it to 3 char. if less than 1000.
codeorder 197 Nearly a Posting Virtuoso

See if this helps.

Dim sCounter As String = "MR/IR/001" '// for testing.
        Dim sTemp As String = Nothing '// temp string.
        sTemp = sCounter.Substring(sCounter.LastIndexOf("/") + 1) '// get all char.s after the last "/".
        sTemp = CInt(CInt(sTemp) + 1).ToString("000") '// increment # +1, and Format it to 3 char. if less than 1000.
        MsgBox(sCounter.Substring(0, sCounter.LastIndexOf("/") + 1) & sTemp) '// display result.
codeorder 197 Nearly a Posting Virtuoso

See if this helps.

DataGridView1.Rows.Add(TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text, TextBox5.Text)
codeorder 197 Nearly a Posting Virtuoso

Check out this thread.

codeorder 197 Nearly a Posting Virtuoso

Move your code from Form1_Paint event to GroupBox1_Paint event.

codeorder 197 Nearly a Posting Virtuoso

>>should i use a timer or what?
I would use a Timer.

As for creating a Splash Screen, I would just create it from a basic Form and not from the built in one from vb.net.
You will have a lot more control over it.

Something simple, using 2 Forms.
Form1 is your Main Form and Form2 will be used as the SplashScreen Form.
Form1 code

Public Class Form1
    Private WithEvents tmr10MinuteTimer As New Timer With {.Interval = 1000, .Enabled = False} '// your Timer.

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '// add this first.
        Form2.FormBorderStyle = Windows.Forms.FormBorderStyle.None '// no border.
        Form2.ShowInTaskbar = False '// do not show Icon of your Splash Screen in TaskBar.
        Form2.ShowDialog() '// load the Splash Screen.
        '// the code following that Form2.ShowDialog will not run until Form2 is closed.

        '//------ other code here if needed.

        '// start Timer after everything is loaded.
        tmr10MinuteTimer.Start()
    End Sub

    Private Sub tmr10MinuteTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmr10MinuteTimer.Tick
        Static iSeconds As Integer = 0
        If Not iSeconds = 600000 Then '// 10 minutes.
            iSeconds += 1 '// add to seconds.
        Else
            tmr10MinuteTimer.Enabled = False '// stop timer.
            MsgBox("10 minutes alert")
        End If
    End Sub
End Class

Form2 code

Public Class Form2
    Private WithEvents tmrSplashScreen As New Timer With {.Interval = 200, .Enabled = True} '// your Timer.

    Private Sub tmrSplashScreen_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmrSplashScreen.Tick
        Static iDelay As Integer …
codeorder 197 Nearly a Posting Virtuoso

Not sure about any other languages, although I doubt that those languages do not have a similar solution to running all previous code before the Application.DoEvents code line and update your app., then run the remaining code.

codeorder 197 Nearly a Posting Virtuoso
TextBox1.Text = "abcdefghi"
        Application.DoEvents() '// do what needs to be done and move on.
        Thread.Sleep(1000)
        TextBox1.Text = "123456789"
codeorder 197 Nearly a Posting Virtuoso

>>thats it?...
I'm afraid so, :D.

Adding that code to the textbox2.TextChanged event, it will constatly set the TextBox2's value to it while typing in your TextBox2.

If you need to add the String's value to a ListBox, use ListBox1.Items.Add(desripition) '// add String to ListBox. .

Unhnd_Exception commented: I'm afraid so :) +1
codeorder 197 Nearly a Posting Virtuoso
desripition = TextBox2.Text
codeorder 197 Nearly a Posting Virtuoso

Place the code in a Button1.Click event and not in the TextBox1.TextChanged event.

codeorder 197 Nearly a Posting Virtuoso

>> ...but I do have a question, why do I need to Dim my integer to 99, is there a reason why? (im just curious)
You do not need it, it is there for testing purposes.
.If getting values from a TextBox, use If Cint(TextBox1.Text) >= 10 AndAlso Cint(TextBox1.Text)<= 1000 Then instead. Cint is to Convert to Integer since .Text is considered a String.

codeorder 197 Nearly a Posting Virtuoso

@codeorder
is that all? or i'll set time to disable it, im sorry im still not familiar with the the time event just starting in vb.net

If you close the Form with the Timer on it, it will stop disabling the TaskManager, otherwise it will keep shutting it down as long as your app. is running.
.This was tested in Windows7, but if you load TaskManager in any other windows system, I believe it will be the same, but you can always replace If selProcess.ProcessName = "taskmgr" Then to ="your taskmanger name here".

It will NOT disable the Ctrl+Alt+Del from loading that screen that asks you to:
.Lock this computer
.Switch User
...
...
.Start Task Manager

But it will shut down the TaskManager if it loaded while your app. runs.

codeorder 197 Nearly a Posting Virtuoso
If Forms(i) Is Nothing Then
codeorder 197 Nearly a Posting Virtuoso

See if this helps.

Dim iMyCoolInteger As Integer = 99 '// your Integer.
        If iMyCoolInteger >= 10 AndAlso iMyCoolInteger <= 1000 Then '// check if value is within your preset bounds.
            MsgBox("Sucess: Integer is within bounds")
        Else '// if not within bounds.
            MsgBox("Fail: Integer is less than or greater than preset bounds", MsgBoxStyle.Critical)
        End If
codeorder 197 Nearly a Posting Virtuoso

Set the registry key to this value:

HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableTaskMgr = dword:1

From online sources and viewing my registry on Windows7, I believe that specified registry key is only for Windows XP, 2000, and maybe a few other systems, but not for Vista and Windows7.

codeorder 197 Nearly a Posting Virtuoso

You can kill the Process as soon as it starts.
1 Timer

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Start()
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        For Each selProcess As Process In Process.GetProcesses
            If selProcess.ProcessName = "taskmgr" Then
                selProcess.Kill()
                Exit For
            End If
        Next
    End Sub
End Class
codeorder 197 Nearly a Posting Virtuoso

I remember reading a while ago on http://www.w3.org/, that for security reasons, you cannot add values to <input type="file"/> .
.If this were to be allowed, files could easily be uploaded from your p.c. without your knowledge.

Best suggestion I can offer, is to click the "Browse" Button.

WebBrowser1.Document.GetElementById("the_file").InvokeMember("click")
codeorder 197 Nearly a Posting Virtuoso

See if this helps.

Dim dTotal As Double = 0 '// for adding total.
        For Each itm As ListViewItem In ListView1.Items '// loop thru items.
            With itm.SubItems(1) '// shorten code for Column 2 items.
                '// check if Not Nothing, add to total.
                If Not .Text = Nothing Then dTotal += CDbl(.Text) '// converting currency to Double will remove the $ symbol.
            End With
        Next
        MsgBox("Total : " & CDbl(dTotal).ToString("c")) '// display total with currency format.
Jake.20 commented: Thank you for the code sir. +1
codeorder 197 Nearly a Posting Virtuoso

hi,

i would like to create an uniqueID where it must add +1 behind the CurrentTranxDateTime for the transaction 1 to 10....I have coded as below but the problem is the number doesnt +1 for each transaction.....any1 have idea to solve this.....
eg: 300111 01:45:29 AM 1
300111 01:45:29 AM 2
300111 01:45:29 AM 3

dim CurrentTranxDateTime as date
dim UniqueID as string
            For i As Integer = 1 To 10
           ' UniqueID = CurrentTranxDateTime & i + 1.ToString()
           UniqueID = CurrentTranxDateTime + i.ToString()
            Next i

It does +1, but since you are running a loop and keep changing "the same" value until the loop ends, the value will always be a 10 at the end of your UniqueID .

This will give you all 10 in the same String.

UniqueID &= CStr(CurrentTranxDateTime) & i.ToString & vbNewLine
swathys commented: thank you +0
codeorder 197 Nearly a Posting Virtuoso

This will use 2 ArrayLists.
1 ArrayList is to write lines back to original rtb and the other is to add the Names to be located in the original rtb.

Public Class Form1
    Private arlRtbLines As New ArrayList '// adds rtb1 lines if string is not found in a line.
    Private arlNamesToFind As New ArrayList '// adds the Names that need to be extracted from rtb1.

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        arlRtbLines.Clear() : arlNamesToFind.Clear() '// clear both if needed for new input.
        '// add names to find.
        arlNamesToFind.Add("Rachel Dawkins")
        arlNamesToFind.Add("Laura Philips")
        '// check if items to find have been added.
        RichTextBox2.Clear() '// clear output rtb.
        If Not arlNamesToFind.Count = 0 Then '// check if Names have been added to the Names to Find ArrayList.
            With RichTextBox1
                For Each rtbLine As String In .Lines '// loop thru all rtb1 lines.
                    If Not arlNamesToFind.Contains(rtbLine) Then '// if name is not found.
                        arlRtbLines.Add(rtbLine) '// add line to ArrayList for writing lines back.
                    Else
                        With RichTextBox2
                            If Not .Text = "" Then .Text &= vbNewLine & rtbLine Else .Text = rtbLine '// send line to rtb2.
                        End With
                    End If
                Next
                .Clear() '// clear rtb1 for new input to write the lines back.
                For Each itm As String In arlRtbLines
                    If Not .Text = "" Then .Text &= vbNewLine & itm Else .Text = itm '// add lines back to rtb1.
                Next
            End With
        End If
    End Sub
End Class
codeorder 197 Nearly a Posting Virtuoso

See if this helps.

Dim ExpDate As String = CDate(dgvBlock_Extend.Rows(icnt).Cells("Extend Door & Lift Expiry Date").Value).ToString("yyyyMMdd")
jlego commented: .. +3
codeorder 197 Nearly a Posting Virtuoso

See if this helps.
2 RichTextBoxes, 1 Button

Public Class Form1
    Private arlRtbLines As New ArrayList '// adds rtb1 lines if string is not found in a line.

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim sStringToFind As String = "Rachel Dawkins" '// String to locate.
        arlRtbLines.Clear() '// clear for new input.
        With RichTextBox1
            For Each rtbLine As String In .Lines '// loop thru all rtb1 lines.
                If Not rtbLine.Contains(sStringToFind) Then '// check first if it does not contain, since more lines probably will not.
                    arlRtbLines.Add(rtbLine) '// add line to ArrayList.
                Else
                    RichTextBox2.Text = rtbLine '// send line to rtb2.
                End If
            Next
            .Clear() '// clear rtb1 for new input to write the lines back.
            For Each itm As String In arlRtbLines
                If Not .Text = "" Then .Text &= vbNewLine & itm Else .Text = itm '// add lines back to rtb1.
            Next
        End With
    End Sub
End Class
codeorder 197 Nearly a Posting Virtuoso

See if this helps to load images in a ListView.

Public Class Form1
    '// ImageList used to store images for the ListView.
    Private myImageList As New ImageList With {.ColorDepth = ColorDepth.Depth32Bit, .ImageSize = New Size(45, 45)}
    Private myImagesFolder As String = "C:\TEMP" '// Folder containing images.

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ListView1.LargeImageList = myImageList '// set the ImageList to Listview.
        For Each img As String In My.Computer.FileSystem.GetFiles _
                                            (myImagesFolder, FileIO.SearchOption.SearchTopLevelOnly, "*.png") '// get all .png images from Folder.
            myImageList.Images.Add(Image.FromFile(img)) '// add image to ImageList.
        Next
        '// loop thru all images added to ImageList.
        For i As Integer = 0 To myImageList.Images.Count - 1
            ListView1.Items.Add(New ListViewItem("img " & i + 1, i)) '// add image to ListView. ", i)" is for the image index in your ImageList.
        Next
    End Sub
End Class
codeorder 197 Nearly a Posting Virtuoso
Dim i As Integer = 0
        Dim newItem As New ListViewItem
        With newItem
            If crunches.Checked Then '// since first item, no need to declare as New item.
                .Text = (i + 1).ToString  '// add text Item
                newItem.SubItems.Add(crunches.Text)
                ListView.ListView1.Items.Add(newItem)
            End If
            If legRaises.Checked Then
                newItem = New ListViewItem '// declare as New item.
                .Text = (i + 1).ToString  '// add text Item
                .SubItems.Add(legRaises.Text)
                ListView.ListView1.Items.Add(newItem)
            End If
            '// etc...
        End With
debasisdas commented: nice as always +8
codeorder 197 Nearly a Posting Virtuoso
If crunches.Checked Then newItem.SubItems.Add(crunches.Text)
        If legRaises.Checked Then newItem.SubItems.Add(legRaises.Text)
        '// etc...
codeorder 197 Nearly a Posting Virtuoso

Add more Columns to your ListView, since Column 1 only displays a # and Column 2 will only display your first CheckBox.Text.

codeorder 197 Nearly a Posting Virtuoso

See if this helps since you probably do not have columns added to your ListView.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        With ListView1
            .Columns.Add("Column 1", 100) : .Columns.Add("Column 2", 100) : .Columns.Add("Column 3", 100) '// add Columns, "100" is column.Width.
            .View = View.Details '// display the Columns.
            .FullRowSelect = True '// highlight entire row when item clicked.
        End With
    End Sub
codeorder 197 Nearly a Posting Virtuoso

If you need to clear all the items, then ListView1.Items.Clear() is the appropriate way to do it.
.Although, you can use a For/Next loop to clear items as well.

With ListView1
            For i As Integer = .Items.Count - 1 To 0 Step -1 '// loop backwards thru ListView.
                .Items.Remove(.Items.Item(i)) '// remove item from ListView.
            Next
        End With
        '// looping backwards will not affect the "i" in the loop as looping forwards does when deleting items.

If you need to remove only a single item, then see if this helps.

With ListView1
            If .Items.Count = 0 Then Exit Sub
            If Not .SelectedItems.Count = 0 Then '// check if item is selected.
                .Items.Remove(.SelectedItems(0))
            Else
                MsgBox("Please select an item to remove from ListView.")
            End If
        End With

.Or this.

ListView1.Items.Remove(ListView1.Items.Item(2)) '// remove 3rd item from ListView.
codeorder 197 Nearly a Posting Virtuoso

See if this helps.

Dim arDaysOfWeek() As String = {"mon", "tue", "wed", "thr", "fri", "sat", "sun"} '// days of week in "ddd" format.
        Dim isValidDay As Boolean = False
        Dim arTemp() As String = Nothing
        With TextBox1
            If .Text.Contains("-"c) Then
                arTemp = .Text.Split("-"c)
                For Each myDay As String In arDaysOfWeek '// loop thru days.
                    If myDay = arTemp(0).ToLower Then '// compare values to .Lower, for not case sensitive.
                        isValidDay = True
                        Exit For
                    End If
                Next
            Else
                MsgBox("value must contain ""-""")
                Exit Sub
            End If
        End With
        If isValidDay = False Then
            MsgBox("wrong day format")
            Exit Sub
        End If
        If Not IsNumeric(arTemp(1)) Then
            MsgBox("wrong year format")
            Exit Sub
        End If
        '// rest of code here.
        MsgBox("valid date format")
codeorder 197 Nearly a Posting Virtuoso

See if this helps.

MsgBox(Date.Now.AddDays(90).ToShortDateString)
        MsgBox(Date.Now.AddDays(-90).ToShortDateString)
msqueen082 commented: very helpful..thank you +0
codeorder 197 Nearly a Posting Virtuoso

See if this helps.

Dim lvItem As New ListViewItem(TextBox1.Text) '// declare new ListView item and set TextBox.Text as item.Text.
        With lvItem.SubItems
            .Add(ComboBox1.Text) '// SubItem 1 for Column 2.
            .Add(ComboBox2.Text) '// SubItem 2 for Column 3.
        End With
        ListView1.Items.Add(lvItem) '// add item to ListView.
codeorder 197 Nearly a Posting Virtuoso

See if this helps.

With ListView1 '// shorten code.
            If Not .Items.Count = 0 Then '// check if items in ListView.
                Dim sNameSearch As String = InputBox("Type in the name of the member to search for.", "Search for gym member")
                '// search ListView for item.
                Dim foundItem As ListViewItem = .FindItemWithText(sNameSearch, True, 0, False)
                '// pressing Cancel in InputBox will return "" as a value.
                If Not sNameSearch = "" Then '// if not Cancel or not an empty value.
                    If foundItem IsNot Nothing Then '// if item has been found.
                        .MultiSelect = False '// disable MultiSelect to only select the found item.
                        .TopItem = foundItem '// bring item to top of ListView without having to scroll.
                        foundItem.Selected = True '// select item to highlight.
                        .MultiSelect = True  '// enable MultiSelect again if needed.
                        .Select() '// .Select ListView to display the highlighted item.
                    End If
                End If
            Else
                MsgBox("cannot search for something if it isn't there", MsgBoxStyle.Information) '// if no items in ListView.
            End If
        End With

Not sure if you are aware that using "1" as Start Index, will start the search at the second item added in the ListView.

codeorder 197 Nearly a Posting Virtuoso

If this is for a ListView, see if this helps.

With ListView1
            If Not .SelectedItems.Count = 0 Then '// check if item is selected.
                .SelectedItems(0).SubItems(1).Text = "Logged Out" '// change .Text of .SubItem.
                '// .SubItems(1) = column 2, .SubItems(2) = column 3, etc..
            Else
                MsgBox("Please select a ""specified personnel"" to log out.", MsgBoxStyle.Information)
            End If
        End With
codeorder 197 Nearly a Posting Virtuoso
Private bAllowF2KeyPress As Boolean = True

    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
        If bAllowF2KeyPress = True Then
            If e.KeyCode = Keys.F2 Then If Button1.Enabled = True Then Button1.Enabled = False '// Disable.
        End If
        If e.KeyCode = Keys.F12 Then
            If Button1.Enabled = False Then Button1.Enabled = True '// Enable.
            bAllowF2KeyPress = False '// set to False to not allow the F2 key to disable Button.
        End If
    End Sub
codeorder 197 Nearly a Posting Virtuoso
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.KeyPreview = True '// keep focus of keys on Form.
    End Sub
    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
        If e.KeyCode = Keys.F2 Then If Button1.Enabled = True Then Button1.Enabled = False '// Disable.
        If e.KeyCode = Keys.F12 Then If Button1.Enabled = False Then Button1.Enabled = True '// Enable.
    End Sub
End Class
codeorder 197 Nearly a Posting Virtuoso

I personally would use a ListView for a "time-in, time-out program".

codeorder 197 Nearly a Posting Virtuoso

See if this helps.

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim x As New Memory
        MsgBox(x.GetMemory)
        End
    End Sub
End Class

Public Class Memory
    Public Function GetMemory() As String
        Dim MemBitSize As String = CStr(My.Computer.Info.TotalPhysicalMemory)
        Select Case CDec(MemBitSize)
            Case 0 To CDec(999.999)
                MemBitSize = Format(CInt(CDec(MemBitSize)), "###,###,###,###,##0 bytes")
            Case 1000 To CDec(999999.999)
                MemBitSize = Format(CInt(CDec(MemBitSize) / 1024), "###,###,###,##0 KB")
            Case 1000000 To CDec(999999999.999)
                MemBitSize = Format(CInt(CDec(MemBitSize) / 1024 / 1024), "###,###,##0 MB")
            Case Is >= 1000000000
                MemBitSize = Format(CInt(CDec(MemBitSize) / 1024 / 1024 / 1024), "#,###.00 GB")
        End Select
        Return MemBitSize
    End Function
End Class
codeorder 197 Nearly a Posting Virtuoso
MsgBox(Format((My.Computer.Info.TotalPhysicalMemory / 1024) / 1024, "###,###,##0.00 MB"))
        MsgBox(Format((My.Computer.Info.TotalPhysicalMemory / 1024) / 1024 / 1024, "###,###,##0 GB"))
codeorder 197 Nearly a Posting Virtuoso

I am personally not clear of what GetServerDateTime returns/is/or does, but see if this helps.

Dim dtServer As DateTime = CDate(Format(GetServerDateTime, "MM/dd/yyyy hh:mm:ss tt")).AddMinutes(+2) '// server date/time.
        Dim dtUser As DateTime = CDate(Format(Now, "MM/dd/yyyy hh:mm:ss tt")) '// date/time on user p.c..
        If dtServer >= dtUser Then '// check if the server date/time +2 minutes, equals or is greater than the users p.c. time.
            MsgBox("allow")
        Else
            MsgBox("cancel")
        End If
swathys commented: thank you so much your reply solve my problem ! +0
codeorder 197 Nearly a Posting Virtuoso

See if this helps.

MsgBox(Format(Now.AddMinutes(5), "MM/dd/yyyy hh:mm:ss tt"))
        MsgBox(Format(Now.AddMinutes(-5), "MM/dd/yyyy hh:mm:ss tt"))