codeorder 197 Nearly a Posting Virtuoso

This does not relate to your question, but I hope it helps.

On Form1 you have a Function: Private Function CurrLanguage(ByVal str As String) which returns Nothing: Return ("") In the case you need to return something as a value to something else, use a Function.

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Text = setTitle(Me.Text)
    End Sub

    Private Function setTitle(ByVal str As String) As String
        Return str & " - added Text"
    End Function
End Class

Otherwise if just setting a value, use a Sub.

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        setTitle(Me.Text)
    End Sub

    Private Sub setTitle(ByVal str As String)
        Me.Text = str & " - added Text"
    End Sub
End Class
codeorder 197 Nearly a Posting Virtuoso

See if this helps.

Add a Public String in Form2 to store the language selected and add a Parameter to the Function.
Form2

Public sLanguageSelected As String

    Private Sub PlayFlash(ByVal selectedCurrentLanguage As String)
        FlashObj.Stop()
        If selectedCurrentLanguage = "LANG_MALAY" Then
            FlashObj.Movie = MultimediaPath & "\Ezy1-agency-Bahasa.swf"
        ElseIf selectedCurrentLanguage = "LANG_ENG" Then
            FlashObj.Movie = MultimediaPath & "\Ezy2-agency-English.swf"
        ElseIf selectedCurrentLanguage = "LANG_CHINESE" Then
            FlashObj.Movie = MultimediaPath & "\Ezy3-agency-Chinese.swf"
        End If
        FlashObj.Play()
    End Sub
    Private Sub frmStep1_AgencyDirect_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ReadPATCfgXML(4)
        Call ReadISTPosMalaysiaXML(0)
        '//=======================
        PlayFlash(sLanguageSelected) '// since language has already been sent from Form1, use that as a Parameter.
        '=======================\\
        Me.Visible = False
        countvar = 0
        tmrShowTimeOutDlg.Enabled = True
    End Sub

Now just set the String in Form2 from Form1.
Form1

Private Function CurrLanguage(ByVal str As String)
        If str = "Malay" Then
            Form2.sCurrentLanguage = "LANG_MALAY"
            ToNextScreen()
        ElseIf str = "English" Then
            Form2.sCurrentLanguage = "LANG_ENG"
            ToNextScreen()
        ElseIf str = "Chinese" Then
            Form2.sCurrentLanguage = "LANG_CHINESE"
            ToNextScreen()
        End If
        Return ("")
        Call resettimer()
    End Function
codeorder 197 Nearly a Posting Virtuoso

See if this helps.

Public Class Form1
    Private myItemPrices() As Double = {4.95, 6.87, 8.52, 2.99, 0.71, 0.5, 0.99} '// item Prices.
    Private myTax As Double = 0.06 '// Tax used to add to Total Price.

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        With ListBox1.Items
            .Add("Small Coffee") : .Add("Medium Coffee") : .Add("Large Coffee") : .Add("Bagel")
            .Add("Cream") : .Add("Sugar") : .Add("Lid")
        End With
        Button1.Text = "New Order"
    End Sub

    '// New Order.
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ListBox2.Items.Clear() '// clear Orders from ListBox.
        Label1.Text = CDec("0").ToString("c") '// reset Total Price Label.
    End Sub

    '// items the user can choose from.
    Private Sub ListBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.DoubleClick
        If Not ListBox1.SelectedIndex = -1 Then '// check if item is selected since -1 equals a no item selected index.
            ListBox2.Items.Add(ListBox1.SelectedItem) '// add Item to Order List.
            '// get Total Price.
            getTotalPrice(ListBox1, ListBox2, Label1)
        End If
    End Sub

    '// items on the order list. 
    Private Sub ListBox2_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox2.DoubleClick
        If Not ListBox2.SelectedIndex = -1 Then '// check if item is selected since -1 equals a no item selected index.
            ListBox2.Items.Remove(ListBox2.SelectedItem) '// remove item from Order List.
            '// get Total Price.
            getTotalPrice(ListBox1, ListBox2, Label1)
        End If
    End Sub

    Private Sub getTotalPrice(ByVal itemsListListBox As ListBox, ByVal orderListListBox As ListBox, ByVal priceTotalLabel As Label)
        Dim myTotal As Double = 0
        For Each itm As String In orderListListBox.Items '// loop thru order items. …
codeorder 197 Nearly a Posting Virtuoso

You probably need to use a For/Next loop.

Label1.Text = "" '// clear all from receipt.
        For Each bookAdded As String In ComboBox1.Items '// loop thru all items.
            '// check if Not empty, add newLine and book, else just add book.
            If Not Label1.Text = "" Then Label1.Text &= vbCrLf & bookAdded Else Label1.Text = bookAdded
        Next
codeorder 197 Nearly a Posting Virtuoso

Not quite clear. Could you provide just the needed info?

codeorder 197 Nearly a Posting Virtuoso

psa112269@yahoo, try removing the Me.Close() from your btnExit.Click and add it as the last line of code in that Sub.

If you still have issues, start a new thread of your own, for your "own" questions.
Do not spam other members' alerts with your replies. Thanks.

codeorder 197 Nearly a Posting Virtuoso

>>Please tell me where i'm going wrong as the message box displays 0.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        var = TextBox1.Text
        Form2.Show()
    End Sub

For future references @Kui, start you own thread for your "own" questions. Thanks.

codeorder 197 Nearly a Posting Virtuoso

>>But if the line doesn't starts with the word "leaning daniweb.com" then how will i do it.
Use .Contains("your text") instead of .StartsWith("your text") .

>>Also, how will i do it if there are multiple lines starting with "leaning daniweb.com"
>>And i want to get all the lines starting with leaning daniweb.com
Don't Exit For to exit the loop and add to the .Text in the other TextBox.

TextBox2.Clear() '// clear for new data.
        For Each txtLine As String In TextBox1.Lines '// loop thru all lines in TextBox.
            If txtLine.Contains("leaning daniweb.com") Then '// check if line .Contains a specified String.
                '// If Not empty Then add new line and content, Else just add content.
                If Not TextBox2.Text = "" Then TextBox2.Text &= vbNewLine & txtLine Else TextBox2.Text = txtLine
            End If
        Next
codeorder 197 Nearly a Posting Virtuoso

For vb6 questions, please use this forum.
Visual Basic 4 / 5 / 6 Forum
Thanks.

codeorder 197 Nearly a Posting Virtuoso

You can save the file to AppData or LocalAppData Folder.
Those folders are there for such reasons and do not need any administrator permissions on non-administrator systems.

Dim myLocalAppDataFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
        Process.Start(myLocalAppDataFolder)

I would create a Folder just for my application in either one of those folders and use it as needed.

codeorder 197 Nearly a Posting Virtuoso

You could use this to get a specified line from the TextBox.

TextBox2.Text = TextBox1.Lines(2) '// get line 3.

Or you could loop through all the lines.

For Each txtLine As String In TextBox1.Lines '// loop thru all lines in TextBox.
            If txtLine.StartsWith("leaning daniweb.com") Then '// check if line .StartsWith a specified String.
                TextBox2.Text = txtLine '// get line content.
                Exit For '// exit loop since line was located.
            End If
        Next
codeorder 197 Nearly a Posting Virtuoso

>>then, how to put intcheckboxesChecked.tostring into a label or a textbox?
Why not add it as you did in your original code, just following the For/Next loop?

codeorder 197 Nearly a Posting Virtuoso

See if this helps.

Dim myFileName As String = "C:\test.exe"
        IO.File.WriteAllBytes(myFileName, My.Resources.testApp)
        If IO.File.Exists(myFileName) Then Process.Start(myFileName)
xxxferraxxx commented: thanks +1
codeorder 197 Nearly a Posting Virtuoso

See if this helps.

ComboBox1.Items.Clear() '// clear for new input.
        For i As Integer = 0 To 99
            '// since you will get more #'s that are greater than 9, use "If Not" first.
            If Not i < 10 Then ComboBox1.Items.Add(i) Else ComboBox1.Items.Add("0" & i)
        Next
codeorder 197 Nearly a Posting Virtuoso

See if this helps.

Public Class Form1
    Private myFile As String = "C:\test.html" '// File for testing.

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Show()
        '// send file lines as a Array.
        getLinks(IO.File.ReadAllLines(myFile))
    End Sub

    Private Sub getLinks(ByVal htmlContentLines() As String)
        Dim iStartIndex, iEndIndex As Integer '// used to locate content to extract.
        For Each htmlLine As String In htmlContentLines '// loop thru all lines.
            If htmlLine.Contains("<div class=""tree tree-top""") Then '// locate lines that contain your links.
                iStartIndex = htmlLine.IndexOf("http://") '// get start location of link.
                iEndIndex = htmlLine.IndexOf("""", iStartIndex) '// get end location of link.
                MsgBox(htmlLine.Substring(iStartIndex, iEndIndex - iStartIndex)) '// extract link.
            End If
        Next
    End Sub
End Class
codeorder 197 Nearly a Posting Virtuoso

Replace line 4 from your posted code with this.

Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream, System.Text.Encoding.Default)
codeorder 197 Nearly a Posting Virtuoso

Why not create a project that will go through the entire database and correct code?
CrLf is nothing but a line break, like vbNewLine.

See if this helps to catch the CrLf.

Dim sTemp As String = "some" & vbNewLine & vbNewLine & "text"
        If sTemp.Contains(CChar(vbCrLf)) Then
            MsgBox(sTemp) '// Display before.
            sTemp = sTemp.Replace(vbCrLf & vbCrLf, " ") '// correct if needed.
            MsgBox(sTemp) '// Display after.
        End If
codeorder 197 Nearly a Posting Virtuoso

See if this helps.

Public Class Form1
    Private myCoolConfigFile As String = "C:\test.txt" '// your File to edit.
    Private arTemp() As String = Nothing '// String Array to load/modify/save File lines.
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If IO.File.Exists(myCoolConfigFile) Then
            arTemp = IO.File.ReadAllLines(myCoolConfigFile) '// Load each File line as a array.
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        '// editFileContent(line you want to locate, content used to modify the next line)
        editFileContent("[pos]", TextBox1.Text)
    End Sub
    Private Sub editFileContent(ByVal lineContentToLocate As String, ByVal coolContentUsedToModifyNextLine As String)
        If Not arTemp.Length = 0 Then '// check if File lines are loaded.
            For i As Integer = 0 To arTemp.Length - 1 '// loop thru all lines.
                If arTemp(i) = lineContentToLocate Then '// check if line equals the line you need to find.
                    arTemp(i + 1) = coolContentUsedToModifyNextLine '// change the next line in your array.
                    Exit For '// exit the loop since done editing.
                End If
            Next
            IO.File.WriteAllLines(myCoolConfigFile, arTemp) '// Save modified File.
            MsgBox("File edited and saved.")
        End If
    End Sub
End Class

If you need to edit another line, use: editFileContent("[lastsave]", TextBox1.Text) . TextBox1.Text is the content to write to the file.

codeorder 197 Nearly a Posting Virtuoso

See if this helps.
1 Button, 1 PictureBox

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        With PictureBox1
            .Left += 5
            .Top += 5
        End With
    End Sub

To change direction of movement, use .Left -= 5 , etc..

codeorder 197 Nearly a Posting Virtuoso

See if this helps to add a Toggle Button Control to the ToolStrip and respond as needed.
2 Forms, 1 ToolStrip(on Form1)

Public Class Form1
    '// New CheckBox. (Appearance.Button changes a CheckBox to a Toggle Button)
    Public WithEvents cbNotes As New CheckBox With {.Width = 75, .Text = "Notes", .Appearance = Appearance.Button, .Cursor = Cursors.Hand}

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '//--- Add CheckBox to ToolStrip.
        Dim myCtlHost As New ToolStripControlHost(cbNotes)
        ToolStrip1.Items.Add(myCtlHost) '---\\
    End Sub

    Private Sub cbNotes_CheckStateChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbNotes.CheckStateChanged
        If cbNotes.Checked Then
            Form2.MdiParent = Me
            Form2.Show()
        Else
            Form2.Close()
        End If
    End Sub
End Class
Public Class Form2

    Private Sub Form2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        If Form1.cbNotes.Checked Then Form1.cbNotes.Checked = False '// uncheck when closing.
    End Sub
End Class

If you just want to use a Button on the ToolStrip, see if this helps.

Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
        With ToolStripButton1
            If Not .Checked Then
                Form2.MdiParent = Me
                Form2.Show()
                .Checked = True '// Check Button.
            Else
                Form2.Close()
                .Checked = False '// UnCheck Button.
            End If
        End With
    End Sub
codeorder 197 Nearly a Posting Virtuoso

Use a ListView for Columns.

With ListView1.Columns '// add Columns.
            .Add("Process Name", 100) : .Add("User Name", 100) : .Add("CPU", 100) : .Add("Memory", 100) : .Add("Description", 100)
        End With
        ListView1.View = View.Details '// Display Columns.
        '// get Processes.
        Dim Prc As Process() = Process.GetProcesses
        For x As Integer = 0 To UBound(Prc)
            Dim newItem As New ListViewItem(Prc(x).ProcessName) '// Item.Text. for column 1.
            newItem.SubItems.Add("User Name") '// column 2.
            newItem.SubItems.Add("CPU") '// column 3.
            newItem.SubItems.Add("Memory") '// column 4.
            newItem.SubItems.Add("Description") '// column 5.
            ListView1.Items.Add(newItem) '// add item to ListView.
        Next
codeorder 197 Nearly a Posting Virtuoso

Also, see if this helps to extract data from a String or .Text.

With TextBox1
            .Text = "aaa bbb ccc <e2>code</e2> aaa bbb ccc"
            Dim iStartIndex As Integer = .Text.IndexOf("<e2>") + 4 '// +4 to exclude the "<e2>" characters.
            '// .IndexOf(char./string to locate, Start search from this Index.)
            Dim iEndIndex As Integer = .Text.IndexOf("</e2>", iStartIndex)
            '// .Substring(Start Index of Substring, length of Substring to extract)
            TextBox2.Text = TextBox1.Text.Substring(iStartIndex, iEndIndex - iStartIndex) & "order :D"
        End With
codeorder 197 Nearly a Posting Virtuoso

Check out this link.

codeorder 197 Nearly a Posting Virtuoso

See if this helps to loop through the 2D Array.

Dim iMathsAverage As Integer = 0, iEnglishAverage As Integer = 0, iScienceAverage As Integer = 0
        For i As Integer = 0 To StudentArray.GetLength(0) - 1 '// loop thru all Arrays.
            '// add values.
            iMathsAverage += CInt(StudentArray(i, 1))
            iEnglishAverage += CInt(StudentArray(i, 2))
            iScienceAverage += CInt(StudentArray(i, 3))
        Next
        '// Result.
        MsgBox("Math: " & iMathsAverage & vbNewLine & "English: " & iEnglishAverage & vbNewLine & "Science: " & iScienceAverage)
codeorder 197 Nearly a Posting Virtuoso

There should be no issues if having the CheckBoxes in one Panel and TextBoxes in another. Your code locates the Panel and looks for a certain control within it. txtTest.Text = CType(pnlChk.Controls(Chk.Tag.ToString), TextBox).Text You could add all of your controls to the Form, not Panels, and loop through all of them to locate only your "txt#" TextBoxes.

For Each ctl As Control In Me.Controls
            If TypeOf ctl Is TextBox AndAlso IsNumeric(ctl.Name.Substring(ctl.Name.LastIndexOf("t") + 1)) Then
                ctl.BackColor = Color.LightSteelBlue
            End If
        Next

That will locate all TextBoxes that have a # at the end of the .Name and the letter prior to the number is "t".

You could however have the TextBoxes.Names end with "_x" for example, then only check If TypeOf ctl Is TextBox AndAlso ctl.Name.EndsWith("_x") Then .

codeorder 197 Nearly a Posting Virtuoso

I just created a new project with your provided code, added "txt1" to chk1.Tag and a few other CheckBoxes, and even left out some .Tags empty. It did not crash here, ran as it should.
Only time i got it to error with: Object reference not set to an instance of an object. is when I changed the .Tag for chk4 from "txt4" to "test4". Seems that one of your .Tags, if not all, do not have the proper Name(s) of the TextBox(es).

You could add a MsgBox in the For/Next loop to locate which CheckBox cause this issue.

If Not Chk.Tag Is Nothing Then MsgBox(Chk.Tag)
codeorder 197 Nearly a Posting Virtuoso

See if this helps.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        UsernameKey("Visa")
    End Sub
    Private Sub UsernameKey(ByVal str As String)
        If str = "Visa" OrElse str = "Master" OrElse str = "Meps" Then
            MsgBox(str)
        End If
    End Sub

Not sure why you were using a Function since it did not have to return anything, but most of all, you were checking the Function for a value instead of checking "str" for the value.

codeorder 197 Nearly a Posting Virtuoso

Could be that the CheckBox.Tag is empty.

If Not Chk.Tag Is Nothing Then txtTest.Text = CType(pnlChk.Controls(Chk.Tag.ToString), TextBox).Text

Or you could use this and skip using the .Tag of a CheckBox entirely.

'// use "txt" and the # at the end of each CheckBox's Name to locate control.
                txtTest.Text = CType(pnlChk.Controls("txt" & Chk.Name.Substring(Chk.Name.IndexOf("k") + 1)), TextBox).Text

If only needing the last TextBox's .Text, why not only set it once?

Dim DisCheckBox As CheckBox() = {chk1, chk2, chk3}
        Dim cb As New CheckBox '// sets the checked CheckBox.
        For Each Chk In DisCheckBox
            If Chk.CheckState = CheckState.Checked Then cb = Chk '// locate the CheckBox if checked.
        Next
        If Not cb.Name = "" Then '// check if cb has a .Name.  gets added if checked.
            '// use "txt" and the # at the end of each CheckBox's Name to locate control.
            txtTest.Text = CType(pnlChk.Controls("txt" & cb.Name.Substring(cb.Name.IndexOf("k") + 1)), TextBox).Text
        End If
codeorder 197 Nearly a Posting Virtuoso

Probably the best solution is to use a WebBrowser, especially if you need to login to your site.
This should help to extract data from WebBrowser and if you need to login to a website, this should help.

codeorder 197 Nearly a Posting Virtuoso

See if this thread helps with extracting data from a website. Should be easy to have the code use HTTP instead of a WebBrowser.

codeorder 197 Nearly a Posting Virtuoso

Can you provide a link to such a site? Should help with narrowing down a possible solution.

codeorder 197 Nearly a Posting Virtuoso

See if this helps.

If Not RichTextBox1.Text = "" Then '// if Not empty, add a New line and content.
            RichTextBox1.Text &= vbNewLine & TextBox1.Text & " - " & TextBox2.Text
        Else '// if empty, just add content.
            RichTextBox1.Text = TextBox1.Text & " - " & TextBox2.Text
        End If
        '// Clear TextBoxes.
        TextBox1.Clear() : TextBox2.Clear()
codeorder 197 Nearly a Posting Virtuoso

You could declare Private arRectangles(2, 2) As String and set values as: arRectangles(0, 0) = "5, 40, 50, 100" . Then you will need to use similar code as posted in my first reply to draw the Rectangles. The CInt part after splitting the String into 4 Arrays. CInt(arTemp(0)), CInt(arTemp(1)), CInt(arTemp(2)), CInt(arTemp(3))

codeorder 197 Nearly a Posting Virtuoso

More than likely using a For/Next loop inside another.
If you still have questions regarding this new issue, start a new thread.

codeorder 197 Nearly a Posting Virtuoso

See if this helps.

Public Class Form1
    Private myGraphics As Graphics '// for Drawing.
    Private arRectangles(2, 2) As Rectangle '// Rectangle 2D Array.
    Private penBlack As New Pen(Color.Black, 3) '// Pen Default Color.

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '// add some Rectangles to your 2D Array.
        arRectangles(0, 0) = New Rectangle(5, 40, 50, 100) '// New Rectangle(load values from database here)
        arRectangles(0, 1) = New Rectangle(150, 90, 50, 75)
        arRectangles(1, 0) = New Rectangle(75, 40, 180, 25)
        arRectangles(2, 2) = New Rectangle(5, 200, 250, 25)
        myGraphics = Me.CreateGraphics '// initialize.
        Me.Show()
        '// Draw Rectangles.
        drawRectangle(0, 0) : drawRectangle(0, 1) : drawRectangle(1, 0) : drawRectangle(2, 2)
    End Sub

    Private Sub drawRectangle(ByVal selectedArray As Integer, ByVal selectedRectangle As Integer)
        myGraphics.DrawRectangle(penBlack, arRectangles(selectedArray, selectedRectangle)) '// draw Rectangle.
    End Sub
End Class
codeorder 197 Nearly a Posting Virtuoso

See if this helps to block a key from being typed into a TextBox.

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If e.KeyChar = Chr(AscW("-")) Then '// check if "-" key has been pressed.
            '// ToolTip code here.
            e.Handled = True '// Cancel the key pressed.
        End If
    End Sub
codeorder 197 Nearly a Posting Virtuoso

See if this helps to check the Clipboard data for a valid URL.

If Clipboard.ContainsData(DataFormats.Text) Then '// check if Data in Clipboard is Text.
            Dim sTemp As String = Clipboard.GetData(DataFormats.StringFormat).ToString '// get Data.
            '// check if Data .StartsWith("http://") to make sure it is a URL
            '--- AndAlso check if the last part ends with a ".", common for files that download(.exe,.png, .etc.).
            If sTemp.StartsWith("http://") AndAlso sTemp.Substring(sTemp.LastIndexOf("/")).Contains(".") Then
                TextBox1.Text = sTemp '// add Data to TextBox.
            Else '// if not a valid URL, notify user.
                MsgBox("Invalid URL.")
            End If
        End If
codeorder 197 Nearly a Posting Virtuoso

If you need to get the byte count for a String, see if this helps.

Dim sTemp As String = "GetByteCount"
        MsgBox(System.Text.Encoding.UTF8.GetByteCount(sTemp))

Note: There are other types of Encoding other than UTF8.

codeorder 197 Nearly a Posting Virtuoso

>plz give d code to me
"Yes Sir!" :D

See if this helps to check a ListBox if it already contains an item, if not add item.
2 ListBoxes

Public Class Form1
   
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        With ListBox1.Items '// add items for testing.
            .Add("item 1") : .Add("item 2") : .Add("item 3") : .Add("item 4") : .Add("item 5")
        End With
    End Sub

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        If Not ListBox2.Items.Contains(ListBox1.SelectedItem) Then '// check if item is Not in ListBox2.
            ListBox2.Items.Add(ListBox1.SelectedItem) '// add item.
        Else '// if item already in ListBox2, notify user.
            MsgBox("This item is already in ListBox2.", MsgBoxStyle.Information)
        End If
    End Sub
End Class
codeorder 197 Nearly a Posting Virtuoso

try label1.text = (2+ 3 ).tostring , see if same result.

codeorder 197 Nearly a Posting Virtuoso

>What the h.ll I can do?
Test out different theories and see which results better your application.
You have all the needed resources in this thread to do so, you just have to find the correct code equation to do it with. That is not for me to do. I just try and supply suggestions and/or possible solutions, not create entire applications.

Good luck.

And btw, not a nice scene at all.
>...I just thought that this would make a nice scene...

codeorder 197 Nearly a Posting Virtuoso

Glad I could help.:)

codeorder 197 Nearly a Posting Virtuoso

Even though this thread is Solved, I hope the following link will help others.
http://www.daniweb.com/forums/post1349728.html#post1349728

codeorder 197 Nearly a Posting Virtuoso

...I only started today so simple techniques...

I think it was more difficult to try and come up with a easy to understand solution than to put the code together.:D

1 PictureBox, 3 Buttons(Button2 is not used, but looks good:D)

Public Class Form1
    Private myCoolImagesFullPaths As New ArrayList '// Store full path of images in, just like using a ListBox.
    Private mySelectedCoolImageIndex As Integer = 0 '// determines where the index is in your ArrayList.

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Button1.Text = "Previous" : Button2.Text = "Start" : Button3.Text = "Next"
        '// Add Full Path of images to your ArrayList.
        myCoolImagesFullPaths.Add("C:\test1.png")
        myCoolImagesFullPaths.Add("C:\test2.png")
        myCoolImagesFullPaths.Add("C:\test3.png")
        myCoolImagesFullPaths.Add("C:\test4.png")
        myCoolImagesFullPaths.Add("C:\test5.png")
        '// Load first image in PictureBox.
        PictureBox1.Image = Image.FromFile(myCoolImagesFullPaths(mySelectedCoolImageIndex).ToString)
        '//--- myCoolImagesFullPaths(0)= image 1, myCoolImagesFullPaths(1) = image 2, myCoolImagesFullPaths(2) = image 3, etc.
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Not mySelectedCoolImageIndex = 0 Then '// check if Not at 0.
            mySelectedCoolImageIndex -= 1 '// subtract -1.
            '// add new image from ArrayList.
            PictureBox1.Image = Image.FromFile(myCoolImagesFullPaths(mySelectedCoolImageIndex).ToString) '// load image.
        Else '// if at 0, notify user.
            MsgBox("First Image.", MsgBoxStyle.Information)
        End If
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        '// check if Not the index equals the total images.Count -1. -1 since Index based and starts at 0 not 1.
        If Not mySelectedCoolImageIndex = myCoolImagesFullPaths.Count - 1 Then
            mySelectedCoolImageIndex += 1 '// add + 1 to your Index number.
            PictureBox1.Image = Image.FromFile(myCoolImagesFullPaths(mySelectedCoolImageIndex).ToString) …
codeorder 197 Nearly a Posting Virtuoso

>how to put an equation statement in a label??

Label1.Text = (2 + 2).ToString
codeorder 197 Nearly a Posting Virtuoso

The For/Next loop did not crash when I tested, but has crashed on others.
To not have it crash, since this is due the the items.Count in ListBox1, use this update for the For/Next loop.

For i As Integer = 0 To lstIndexes.Count - 1 Step 4 '// Step 4 skips to every 5 item.
            arlGroup1.Add(ListBox1.Items(lstIndexes(i)))
            '// check if i +1 does not equal or is greater than the items.Count in your List of Integer, Else Exit the loop.
            If Not lstIndexes.Count <= i + 1 Then arlGroup2.Add(ListBox1.Items(lstIndexes(i + 1))) Else Exit For
            If Not lstIndexes.Count <= i + 2 Then arlGroup3.Add(ListBox1.Items(lstIndexes(i + 2))) Else Exit For
            If Not lstIndexes.Count <= i + 3 Then arlGroup4.Add(ListBox1.Items(lstIndexes(i + 3))) Else Exit For
        Next
codeorder 197 Nearly a Posting Virtuoso

See if this helps with explaining a little about "SourcePath" and "DestinationPath".

If .ShowDialog = DialogResult.OK Then
                ' Load the specified file into a PictureBox control.
                PictureBox1.Image = Image.FromFile(.FileName)
                If IO.File.Exists(.FileName) = True Then '// check if file exists by using the FullPath of the file.
                    IO.File.Copy(.FileName, "C:\MyPicture\" & IO.Path.GetFileName(.FileName), True) '//  IO.File.Copy(SourcePath, DestinationPath, Overwrite)
                    '// IO.Path.GetFileName(.FileName) only gets the FileName and Extension of a file and not the FullPath like when using only ".FileName".
                    MsgBox("File Copy Successful.")
                End If
            End If

SourcePath is the original FullPath of a file and DestinationPath is the new FullPath for the file.

codeorder 197 Nearly a Posting Virtuoso

See if this helps about saving and loading a color to/from a file.

Public Class Form1
    Private myFile As String = "C:\test" '// File used to Save/Load Color.
    Private mySelectedCoolColor As New Color '// stores loaded color from File or ColorDialog.

    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        IO.File.WriteAllText(myFile, mySelectedCoolColor.ToArgb.ToString) '// save Color to file as ARGB Color.
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If IO.File.Exists(myFile) Then '// check if file exists.
            mySelectedCoolColor = Color.FromArgb(CInt(IO.File.ReadAllText(myFile))) '// read ARGB Color and set it.
            myCoolThemeColorSub(mySelectedCoolColor) '// send the Color to your Theme Sub.
        End If
        Me.Show()
        Dim myCoolColorDialog As New ColorDialog '// your Color Dialog.
        If myCoolColorDialog.ShowDialog = DialogResult.OK Then '// check if OK clicked.
            mySelectedCoolColor = myCoolColorDialog.Color '// store the color to use for when saving.
            myCoolThemeColorSub(mySelectedCoolColor) '// send the Color to your Theme Sub.
        End If
    End Sub

    Private Sub myCoolThemeColorSub(ByVal myCoolColorToUse As Color)
        For Each ctl As Control In Me.Controls '// loop thru all controls on Form.
            If TypeOf ctl Is Button Then ctl.ForeColor = myCoolColorToUse '// locate Button and change Color.
        Next
    End Sub
End Class
codeorder 197 Nearly a Posting Virtuoso

Could you replicate a car if you did not know what the car looks like minus well know what a car is?

>But, I want that everytime it appends to the file, it replicate the file content plus the new info randomized from the array. If it could do it without reading the file,...
My answer would be that this cannot be done, although I could be wrong.

codeorder 197 Nearly a Posting Virtuoso

How many items is it randomizing? Just the ones from the code in your ArrayList? Then it is not the randomizing taking the time, it is the "loading the file, reading it, and saving it again".