codeorder 197 Nearly a Posting Virtuoso

My apologies, I did not notice the "form will close" from your previous reply. Use the DateSelected event instead of the FormClosing.

Private Sub MonthCalendar1_DateSelected(ByVal sender As Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MonthCalendar1.DateSelected
        Form1.TextBox1.Text = MonthCalendar1.SelectionStart.ToShortDateString  '// .SelectionStart gets the first selected Date.
        Me.Close() '// close Form after selecting Date.
    End Sub
codeorder 197 Nearly a Posting Virtuoso

See if this helps.

Public Class Form2

    Private Sub Form2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Form1.TextBox1.Text = MonthCalendar1.SelectionStart.ToShortDateString  '// .SelectionStart gets the first selected Date.
    End Sub
End Class
codeorder 197 Nearly a Posting Virtuoso

I am personally a bit confused about your issue.
>>it is only can save at c: but cannot at other location such as document and new folder.

Are you trying to "only" save the file to "C:\" and nowhere else?
Or is it that you cannot save the file anywhere else other than "C:\"?

codeorder 197 Nearly a Posting Virtuoso

>>I have problem to sae the lstCustomerStatistic to a txt.file, and later read it agin in for further use.

I know this is a really old thread, but with a total of Views: 425 as of today, this link might help others to save and load a ListBox's items from a File.
how do I save a list in a listbox and it keep saved when I close the application

codeorder 197 Nearly a Posting Virtuoso

See if this helps.

Public Class Form1
    Private myListBoxItemsFile As String = "C:\myListBoxItemsFile.txt" '// your file.

    '// Save to File from ListBox.
    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Dim myCoolWriter As New IO.StreamWriter(myListBoxItemsFile)
        For Each coolItem In ListBox1.Items '// loop thru all items in ListBox.
            myCoolWriter.WriteLine(coolItem) '// write each item to a line.
        Next
        myCoolWriter.Close() '// .Close your File writer.
    End Sub

    '// Load ListBox.
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If IO.File.Exists(myListBoxItemsFile) Then '// check if file exists.
            ListBox1.Items.AddRange(IO.File.ReadAllLines(myListBoxItemsFile)) '// load each line as an item in the ListBox.
        End If
    End Sub
End Class
codeorder 197 Nearly a Posting Virtuoso

Save ListBox items to a File from Form1_FormClosing event, then use the Form1_Load to check if your File exists and if it does, to load the File into your ListBox.

If you need help with this new issue, start a new thread.

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

You can either replace line 6 from the Private Sub savingFile() with sd.RestoreDirectory = True '// restores recent Directory used. , or if you want to use the FilePath from your Label, if a full FilePath, change line 6 to sd.InitialDirectory = IO.Path.GetDirectoryName(lblName.Text) '// extract Folder Path from Full FilePath. , which should load your SaveFileDialog with that specified folder path.

codeorder 197 Nearly a Posting Virtuoso
desripition = TextBox2.Text
codeorder 197 Nearly a Posting Virtuoso

btnAdd.Click event should have your btnform2.Click event code(for adding items to ListBox on Form2) and btnform2.Click should have a Form2.Show or Form2.ShowDialog (.ShowDialog displays the Form as a MsgBox, not allowing access to the Form it was called from, until closed).

codeorder 197 Nearly a Posting Virtuoso

If you leave it as is in line 61 of your previously posted code, for the Private Sub Bbtnadd_Click event, you should have no issues with sTemp not being declared when you need to add the value from it to your ListBox. That is, if the add items to ListBox code is somewhere within the same Sub.

codeorder 197 Nearly a Posting Virtuoso

>>For the button 2, its only saying the message, I need it to be able to go into textbox1 and see if there is a 5 values there or not
Check line 18 of your posted code, the code is there.

About adding items to a ListBox on another Form, use something like Form2.ListBox1.Items.Add(sTemp) '// add to ListBox on Form2.

codeorder 197 Nearly a Posting Virtuoso

You do not need the Boolean anymore, if you are using the Button1.Enabled=True/False.
.Remove Private bIsValidValue As Boolean '// used to validate if TextBox value is valid or not. and also only have your MsgBox code, if you need it, in Button1's.Click event.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

            MsgBox("Valid value in TextBox, proceed with code here...")

    End Sub

I would also set Button1.Enabled=False on Form1_Load.

.Text from a TextBox is a "String".

codeorder 197 Nearly a Posting Virtuoso

My code is to only get a proper 5 digit number, nothing else.

Try this.
Replace bIsValidValue = False '// reset/set to False. at the top of Private Sub TextBox1_TextChanged( , with Button1.Enabled = False AndAlso, replace the bIsValidValue = True '// set to True since it is Valid. from the same event, with Button1.Enabled = True .
When your Button1 enables after typing in the TextBox, you have a valid number.

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

Jake.20, care to share with the rest of us how you solved this issue?

codeorder 197 Nearly a Posting Virtuoso

>>I tried to get help on this on a different thread, but I didnt get any help on specifically for this...
See if this helps.
It contains a Boolean which will allow you to add items to your ListBox or not, depending if a correct value in the TextBox.

Public Class Form1

    Private bIsValidValue As Boolean '// used to validate if TextBox value is valid or not.

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        bIsValidValue = False '// reset/set to False.
        With TextBox1 '// shorten code.
            If .Text = "" Then '// if .Text is empty, clear Label.Text and skip remaining code in this Sub.
                Label1.Text = ""
                Exit Sub
            End If
            If IsNumeric(.Text) Then '// if .Text is Numeric and does not contain letters.
                If .TextLength = 5 Then '// check if length is 5.
                    If CInt(.Text) >= 10000 AndAlso CInt(.Text) <= 99999 Then '// check for value, if greater/less than...
                        Label1.Text = "This is a five digit code :)"
                        bIsValidValue = True '// set to True since it is Valid.
                    Else
                        Label1.Text = "Value must be between 10,000 and 99,999"
                    End If
                Else
                    Label1.Text = "Not a 5 digit code, please renter a new one"
                End If
            Else '// if not Numeric.
                Label1.Text = "Only Numeric values will be accepted"
            End If
        End With
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If bIsValidValue = True Then
            '// add code here to add to …
codeorder 197 Nearly a Posting Virtuoso

I believe your btnAdd should be the Button that adds Items to your ListBox.

Private Sub Bbtnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
      Dim sTemp As String = TextBox1.Text & ":" & TextBox2.Text & ":" & TextBox3.Text & ":" & TextBox4.Text & ":" & TextBox5.Text
      ListBox1.Items.Add(sTemp) '// add to ListBox.
    End Sub
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

If you just need the items from a ListBox added as a new line in a MsgBox, see if this helps.

Dim sTemp As String = Nothing '// store items and new lines.
        For Each itm As String In ListBox1.Items '// loop thru items.
            '// add to String as needed.
            If Not sTemp = Nothing Then sTemp &= vbNewLine & itm Else sTemp = "you ordered :" & vbNewLine & itm
        Next
        MsgBox(sTemp) '// display result.
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

Ok but where do I put that exactly because it keeps coming up with errors and also if you look at my code, you can see that my textbox 1 and 2 are to keep the values between a preset area, did I do this right or does there needs to be a lil more after the then statement and also how do I make a string only so big, like the motoredID is only suppose to be 5 digits long and nothing more or less, how can I do that?

Can you post your entire code for both forms with the code you currently have?

codeorder 197 Nearly a Posting Virtuoso

...of limitless possiblities. When sea dweller's dreams...

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

See if this helps.

Imports mshtml
Public Class Form1
    Private bDownloadImages As Boolean = False '// determine if to download images or not.
    Private myImagesFolder As String = "C:\TEMP\" '// folder for images to be saved to.

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        bDownloadImages = True '// set to True to only download images when needed.
        WebBrowser1.Navigate("http://www.yahoo.com/") '// load page in WebBrowser.
    End Sub

    '// when WebBrowser finishes loading the page...
    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        If bDownloadImages = True Then
            getImages() '// Download Images.
            Application.DoEvents() '// give it time to finish downloading images.
            bDownloadImages = False '// set back to False.
        End If
    End Sub

    Private Sub getImages()
        Dim doc As IHTMLDocument2 = DirectCast(WebBrowser1.Document.DomDocument, IHTMLDocument2)
        Dim imgRange As IHTMLControlRange = DirectCast(DirectCast(doc.body, HTMLBody).createControlRange(), IHTMLControlRange)
        Dim myImagesFileExtenstions() As String = {".png", ".jpg", ".gif"} '// String Array containing your image file .Extensions.
        Dim sImageExtension As String = Nothing '// get file extension from file.
        For Each img As IHTMLImgElement In doc.images
            For Each imgToFind As String In myImagesFileExtenstions '// loop thru all image file .Extensions.
                If img.nameProp.EndsWith(imgToFind) Then '// if it contains,...
                    imgRange.add(DirectCast(img, IHTMLControlElement))
                    imgRange.execCommand("Copy", False, Nothing)
                    Using bmp As Bitmap = DirectCast(Clipboard.GetDataObject().GetData(DataFormats.Bitmap), Bitmap)
                        Static i As Integer = 1
                        sImageExtension = img.nameProp.Substring(img.nameProp.LastIndexOf(".")) '// get file .Extension of image.
                        Select Case sImageExtension '// save image files with proper ImageFormat.
                            Case ".png"
                                bmp.Save(myImagesFolder & "\test" & i & sImageExtension, Imaging.ImageFormat.Png)
                            Case ".jpg"
                                bmp.Save(myImagesFolder & "\test" & i …
codeorder 197 Nearly a Posting Virtuoso
Dim x As String = " abc xyz "
        x = x.TrimStart(" "c).TrimEnd(" "c)
        MsgBox(x)
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

Then your code is not in the Private Sub WebBrowser1_DocumentCompleted(.. event,
and your WebBrowser does not have a page loaded.

I would also save the images under the proper ImageFormat.

Static i As Integer = 1
                    bmp.Save("C:\TEMP\test" & i & ".jpg", Imaging.ImageFormat.Jpeg)
                    i += 1
codeorder 197 Nearly a Posting Virtuoso

1. Add reference to Microsoft HTML Object Library when working with DomDocument .
.File menu, Project/Add Reference.../COM tab/Microsoft HTML Object Library.

2. Add an import to the top of your Form for mshtml .

Imports mshtml '// After adding the reference, Import mshtml.
Public Class Form1
codeorder 197 Nearly a Posting Virtuoso

>>but does an array just sore info from what the person adds or is it permanent code?
Hmm.. Good question.. Does an Array "sore"?:-/
.Will get back to you on that one, like never.:D

If you are referring to the ArrayList, it will not save when the app. closes unless you save the items in the ArrayList to a file and reload them back when loading the app..

To clear the ArrayList at any time, use myList.Clear() since the ArrayList is declared as "myList".

If you need to add values from your 5 TextBoxes, when adding items to the ArrayList, simply add the values of those TextBoxes.

Dim sTemp As String = TextBox1.Text & ":" & TextBox2.Text & ":" & TextBox3.Text & ":" & TextBox4.Text & ":" & TextBox5.Text
        myList.Add(sTemp) '// add to ArrayList.
        ListBox1.Items.Add(sTemp) '// add to ListBox.
codeorder 197 Nearly a Posting Virtuoso

I got rid of the "heavy suit of burden" and got a monkey on my back instead.

(jingda recently changed the avatar image from a samurai to a....... .....
.., ...., hmmm...., ...... a rug?)

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

>>...if someone could help me out on a direction...
See if this helps.

Public Class Form1
    Private myList As New ArrayList '// ArrayList to store info.

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '// this is how you would add values to your ArrayList.
        myList.Add("abc 123 xyz")
        myList.Add("xyz 321 cba")
        '// Load ListBox with the values from ArrayList.
        ListBox1.Items.AddRange(myList.ToArray)
    End Sub
End Class

An ArrayList is basically a ListBox.

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

See if this helps.
2 Buttons, 5 TextBoxes(.Named "txtMenu#")

Public Class Form1
    Private iSelectedTextBox As Integer = 1 '// keeps track of which TextBox is selected.
    Private iFirstTextBox As Integer = 1 '// # of first TextBox, as "txtMenu#".
    Private iLastTextBox As Integer = 5 '// # of last TextBox, as "txtMenu#".  i only used 5 TextBoxes for this sample project.
    Private sNameOfTextBoxes As String = "txtMenu" '// set only the letters from name of TextBoxes, no #'s.

    '// btnUP.
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Not iSelectedTextBox = iFirstTextBox Then '// check if the # set by the TextBox in Focus is not the first TextBox.
            iSelectedTextBox -= 1 '// subtract -1 to move to the TextBox above.
            Me.Controls(sNameOfTextBoxes & iSelectedTextBox).Select() '// select TextBox above.
        Else
            Me.Controls(sNameOfTextBoxes & iFirstTextBox).Select() '// if first TextBox, select it.
        End If
    End Sub

    '// btnDOWN.
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If Not iSelectedTextBox = iLastTextBox Then '// check if the # set by the TextBox in Focus is not the last TextBox.
            iSelectedTextBox += 1 '// add +1 to move to the TextBox below.
            Me.Controls(sNameOfTextBoxes & iSelectedTextBox).Select() '// select TextBox below.
        Else
            Me.Controls(sNameOfTextBoxes & iLastTextBox).Select() '// if last TextBox, select it.
        End If
    End Sub

    '// when a TextBox gets Focus, it will set the # at the end of the TextBox.Name as the # for the iSelectedTextBox.
    Private Sub _txt_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) …
codeorder 197 Nearly a Posting Virtuoso

on Narwhals. The ocean knew no limits.

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

Seems that you are missing your quotations for the .Value.

Dim iCount As Integer = 0
        With DataGridView1
            For i As Integer = 0 To .RowCount - 1 '// loop thru all Rows.
                If .Rows(i).Cells(0).Value = "True" Then iCount += 1 '// check for value and Then only add +1.
            Next
        End With
        txtc.Text = iCount.ToString
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")