Jx_Man 987 Nearly a Senior Poster Featured Poster
Jx_Man 987 Nearly a Senior Poster Featured Poster
Estella commented: nice link +3
Jx_Man 987 Nearly a Senior Poster Featured Poster

Set MultiSelect = 2 - Extend in Listbox properties.
Press "Ctrl" while you select items.

Private Sub Command1_Click()
Dim i As Integer
For i = 0 To List1.ListCount - 1
    If List1.Selected(i) Then
        Text1.Text = Text1 + List1.List(i) + ","
    End If
Next

End Sub
Naruse commented: great help :) +3
Jx_Man 987 Nearly a Senior Poster Featured Poster

if I enter/write B or u nothing happens however if I write E it just appends the entire sentence.

Autocomplete works with knowing the "First Letter" in combobox items.
e.g (three items on combobox)
Austria
Brazil
Canada

So, If you type "c" it wil be Canada but when you type "n" there is nothing to show.

If you want to show items suggestion, you can set Combobox AutoCompleteMode = SuggestAppend and AutoCompleteSource = ListItems

Jx_Man 987 Nearly a Senior Poster Featured Poster

try this :

    Public Sub AutoComplete(ByVal cmb As ComboBox, ByVal e As KeyEventArgs)
        Dim sTypedText As String
        Dim iFoundIndex As Integer
        Dim oFoundItem As Object
        Dim sFoundText As String
        Dim sAppendText As String

        Select Case e.KeyCode
            Case Keys.Back, Keys.Left, Keys.Right, Keys.Up, Keys.Delete, Keys.Down
                Return
        End Select

        sTypedText = cmb.Text
        iFoundIndex = cmb.FindString(sTypedText)

        If iFoundIndex >= 0 Then
            oFoundItem = cmb.Items(iFoundIndex)
            sFoundText = cmb.GetItemText(oFoundItem)
            sAppendText = sFoundText.Substring(sTypedText.Length)
            cmb.Text = sTypedText & sAppendText

            cmb.SelectionStart = sTypedText.Length
            cmb.SelectionLength = sAppendText.Length
        End If

    End Sub

    Private Sub ComboBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ComboBox1.KeyUp
        AutoComplete(ComboBox1, e)
    End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

Using Array :

strmsg = "John Doe der"
Dim a() As String

a = Split(strmsg, " ")
Debug.Print a(UBound(a))
Sawamura commented: good example +3
Jx_Man 987 Nearly a Senior Poster Featured Poster

You want to sort items on listbox?
Try this :

lstCountries.Sorted = True
Jx_Man 987 Nearly a Senior Poster Featured Poster

in which line?

Jx_Man 987 Nearly a Senior Poster Featured Poster

but now i want to select(click) any one row from listview and get all three(NOT TWO) textbox.text from datatable BRAND

Use SQL Statement.

Select BRANID, BRANDNAME, ID From BRAND 
Jx_Man 987 Nearly a Senior Poster Featured Poster
Jx_Man 987 Nearly a Senior Poster Featured Poster

First you must know what the meaning of the error warning.
"Runtime error '381 'Invalid property array index".

You said that vb pointing you in line 2 (List2.Selected(i) = True) when error is came up, it means that your selected index is not available on the list.

Jx_Man 987 Nearly a Senior Poster Featured Poster

So what the problem here?
Provides more information.

Thanks

Jx_Man 987 Nearly a Senior Poster Featured Poster

This should working :

Private Sub Command1_Click()
xSearch = Text1.Text
For i = 0 To Grid.Rows - 1
    If xSearch = Grid.TextMatrix(i, 1) Then
        Grid.Row = Grid.TextMatrix(i, 1)
        For j = 1 To Grid.Cols - 1
            Grid.Col = j
            Grid.CellBackColor = vbCyan
        Next j
    End If
Next i
End Sub
Aurax commented: Thanks!!! +0
Jx_Man 987 Nearly a Senior Poster Featured Poster

welcome and enjoy daniweb.

Jx_Man 987 Nearly a Senior Poster Featured Poster

enjoy daniweb.

Jx_Man 987 Nearly a Senior Poster Featured Poster
Jx_Man 987 Nearly a Senior Poster Featured Poster

This an example about struct of employee combining with array

Module1

Public Type Employee
    EmpNo As Integer
    EmpName As String
    EmpPhone As String
End Type

Public Sub SetEmployee(ByRef emp() As Employee, ByVal i As Integer)
    ReDim emp(i)
End Sub

Public Sub SetEmpData(ByRef emp() As Employee, ByVal i As Integer, ByVal no As Integer, ByVal name As String, ByVal phone As String)
    emp(i).EmpNo = no
    emp(i).EmpName = name
    emp(i).EmpPhone = phone
End Sub

'GetEmpData will return array containing employee details
Public Function GetEmpData(ByRef emp() As Employee, ByVal i As Integer) As Employee
    GetEmpData = emp(i)
End Function

Form1
All inputs will use inputbox and just add two button for set and get employee details

Dim NewEmp() As Employee ' declare array as struct of employee
Dim i As Integer

Private Sub Command1_Click()
   ' how many employee to add
    temp = InputBox("How many employee ?")
    SetEmployee NewEmp, Int(temp - 1)

    ' add employee detail
    For i = 0 To UBound(NewEmp)
        EmpNos = InputBox("Emp " & i + 1 & " No")
        EmpNames = InputBox("Emp " & i + 1 & " Name")
        EmpPhones = InputBox("Emp " & i + 1 & " phone")

        SetEmpData NewEmp, i, EmpNos, EmpNames, EmpPhones
    Next
End Sub

Private Sub Command2_Click()
' Extract detail of employee for each array
For i = 0 To UBound(NewEmp)
    MsgBox GetEmpData(NewEmp, i).EmpNo & "," & GetEmpData(NewEmp, i).EmpName & "," & GetEmpData(NewEmp, i).EmpPhone
Next
End Sub
Estella commented: Very good example... +4
ITKnight commented: Very helpful +2
Jx_Man 987 Nearly a Senior Poster Featured Poster

Is there any way to add the full row that was selected from DataGridView1 to the table "PersonneCopy"?

Yes. Get the value from datagrid and Use INSERT statement to add the selected row to Personnecopy table.

Jx_Man 987 Nearly a Senior Poster Featured Poster

error says : Syntax error (comma) in query expression '(acntId, 5/17/2013 , 'Last , First, Middle')'

'Last , First, Middle'
You want to insert 3 fields but the value of txtSpouseName.Text make compiler confused and rise an error.
compiler might thought that it should be 'Last' , 'First', 'Middle'.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Or you can do this way :

Add Class to your project, named ListViewColumnSorter (You can modify it).
Replace with this following code :

Imports System.Collections
Imports System.Windows.Forms

Public Class ListViewColumnSorter
    Implements System.Collections.IComparer

    Private ColumnToSort As Integer
    Private OrderOfSort As SortOrder
    Private ObjectCompare As CaseInsensitiveComparer

    Public Sub New()
        ' Initialize the column to '0'.
        ColumnToSort = 0

        ' Initialize the sort order to 'none'.
        OrderOfSort = SortOrder.None

        ' Initialize the CaseInsensitiveComparer object.
        ObjectCompare = New CaseInsensitiveComparer()
    End Sub

    Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements IComparer.Compare
        Dim compareResult As Integer
        Dim listviewX As ListViewItem
        Dim listviewY As ListViewItem

        ' Cast the objects to be compared to ListViewItem objects.
        listviewX = CType(x, ListViewItem)
        listviewY = CType(y, ListViewItem)

        ' Compare the two items.
        compareResult = ObjectCompare.Compare(listviewX.SubItems(ColumnToSort).Text, listviewY.SubItems(ColumnToSort).Text)

        ' Calculate the correct return value based on the object 
        ' comparison.
        If (OrderOfSort = SortOrder.Ascending) Then
            ' Ascending sort is selected, return typical result of 
            ' compare operation.
            Return compareResult
        ElseIf (OrderOfSort = SortOrder.Descending) Then
            ' Descending sort is selected, return negative result of 
            ' compare operation.
            Return (-compareResult)
        Else
            ' Return '0' to indicate that they are equal.
            Return 0
        End If
    End Function

    Public Property SortColumn() As Integer
        Set(ByVal Value As Integer)
            ColumnToSort = Value
        End Set

        Get
            Return ColumnToSort
        End Get
    End Property

    Public Property Order() As SortOrder
        Set(ByVal Value As SortOrder)
            OrderOfSort = Value
        End Set

        Get
            Return OrderOfSort
        End Get
    End Property
End Class

In your form :

Public …
Sawamura commented: Great example +4
Jx_Man 987 Nearly a Senior Poster Featured Poster

Read this article : How to Sort ListView Items

Jx_Man 987 Nearly a Senior Poster Featured Poster

No luck?

How about post your cmdquit codes.
It will help..

Jx_Man 987 Nearly a Senior Poster Featured Poster

Try :

Dim MyRnd as New Random
TextBox1.Text = MyRnd.Next(1, 8))
Jx_Man 987 Nearly a Senior Poster Featured Poster

I have tried some but it will not work as I will

If I press the X button on titel bar then
I will it goes to cmdquit where I have to
choose vbyes or vbno.
The tests I haave done just quit the program
at once without any chance to choose.

If vbyes is true then call cmdquit where
it make some backup files.
If vbno then exit sub

As i said in your previous thread (actualy same question)
It much easier to put your backup codes in procedure or function. you can call it in your cmdquit button event or when you press X button or any action when you needed to backup your files.

Hope it helps.

Jx_Man 987 Nearly a Senior Poster Featured Poster

JX
it won't work as I will
Ok it close all but I will
it shall go to cmdquit where
a msgbox is and I can choose
vbyes or vbno
If vbyes=true
then it makes backup of some files
and vbno end the sub

I'm suggesting you to put the backup code in procedure or function. You can call it when you needed, which it in cmdquit button or when you pressing X button.

Try this following codes. Modified as you needed :

Private Sub BackUpDB()
    ' Backup codes here
    MsgBox "backup success"
End Sub

Private Sub cmdquit_Click()
    ' Your cmdquit code here
    ' Call BackUpDB after your vbYes line code.
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Dim state As Integer

    state = MsgBox("Are you realy want to exit this program? ", vbYesNo, "Exit?")
    If state = vbYes Then
        BackUpDB 'call backupdb procedure here
    Else
        Cancel = True ' just cancel exit
    End If
End Sub

Hope it solve your problem.

Jx_Man 987 Nearly a Senior Poster Featured Poster

I just wonder how to enabled the X in the right
upper corner of a form.

What you mean about x mark in the right upper corner? Are you put a button or some other control there?

When I press the X then I will that it goes to cmdquit
and the program is ending.

I don't know why you need make it goes to cmdquit again since you can close your program when you click on X mark (button or any other controls). Like this following code :

Private Sub btnX_Click()
    End
End Sub

But if you want to make it call cmdquit then here is the way.
I assume the x mark as button (but you can use another controls).
Also i don't know what it's in cmdquit but you said about ending the program.

Private Sub cmdquit_Click()
    End
End Sub

Private Sub btnX_Click()
    ' This line of code will call 
    Call cmdquit_Click
End Sub

Or you mean about close button (X) on form title bar?
If yes then you can use form unload event :

Private Sub Form_Unload(Cancel As Integer)
    Call cmdquit_Click
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

Make autocomplete of combobox is different thing with prevent user input in combobox.
You drag us with preventing user input but actualy you want to make autocomplete of combobox.
VB6 and VB.Net has different way to make autocomplete. Autocomplete is an easy task in vb.net.

Here is the vb.net ways :

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim MySource As New AutoCompleteStringCollection
    MySource.AddRange(New String() {"Monday", "Thursday", "Wednesday", "Tuesday", "Friday"})

    ComboBox1.AutoCompleteCustomSource = MySource
    ComboBox1.AutoCompleteMode = AutoCompleteMode.Suggest
    ComboBox1.AutoCompleteSource = AutoCompleteSource.CustomSource
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

It causing of txtAccount_Balance_TextChanged event.
When you clear textbox txtAccount_Balance it makes that event work and rise an error. It happen because there are no numbers in the textbox after clear the textbox but empty string.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Try this :

Private Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress
    If CType(sender, ComboBox).FindString(CType(sender, ComboBox).Text, 1) = True Then
        'if it doesnt exist then remove the last character/s that dont match and set the cursor position to the end
        CType(sender, ComboBox).Text = CType(sender, ComboBox).Text.Substring(0, CType(sender, ComboBox).Text.Length - 1)
        CType(sender, ComboBox).SelectionStart = CType(sender, ComboBox).Text.Length

        e.Handled = True

        ' accepting backspase
        If Asc(e.KeyChar) = 8 Then
            e.Handled = False
        End If
    End If
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

Post your code here. How far you doing this. Show some effort.
we Will trying to help you.

Read this thread about how to read txt file.

Jx_Man 987 Nearly a Senior Poster Featured Poster

If you bet with large amount data and security then mysql, mssql or oracle is the best choise.
For user configuring is not difficult as you thinking.
Install your program and database as packet.
To make it easy for user then your program must facilitate it. Can create database in first using and know the server name.
So user just use it without many configurating.

Jx_Man 987 Nearly a Senior Poster Featured Poster

You're welcome.
Don't forget to mark this thread as solved

Happy coding :)

Jx_Man 987 Nearly a Senior Poster Featured Poster

You will get this error because using of Val() function.
e.g : Val(txtbox_tolagoldweight.Text * 96), you just multiply string with number.

try this :

Sub kaat()
    goldkaatinratti = (((Val(TextBox1.Text) * 96) + (Val(TextBox2.Text) * 8)) + (Val(TextBox3.Text) * 8)) / 96
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

@Jx Man he said datagridview not listview bro

My bad.. Here's for the datagridview :

Dim i As Integer = DataGridView1.CurrentRow.Index
 With DataGridView1
     TextBox1.Text = DataGridView1.Item(0, i).Value
     TextBox2.Text = DataGridView1.Item(1, i).Value
 With
Jx_Man 987 Nearly a Senior Poster Featured Poster

How to get current Selected Row in dataGridview

try this :

Dim i As Integer = CInt(ListView1.SelectedItems(0).Index)

TextBox1.Text = ListView1.Items(i).SubItems(0).Text
TextBox2.Text = ListView1.Items(i).SubItems(1).Text
Jx_Man 987 Nearly a Senior Poster Featured Poster

Have you ever heard about BeginTrans,CommitTrans and RollbackTrans?
You can do this with Rollback.
Search the google about it.
See this article, this article, this and this.

dnk commented: Good links sir. very helpful +2
Jx_Man 987 Nearly a Senior Poster Featured Poster

do you know how to make pause button? i already try to make it after i click play button the song will not continue but it will be restart. this is my code for pause button.

You need to check what is the wmp state. Simple logic here. If state is pause then play the current song else play the selected song.
This is the modification of PlaySong Procedure :

Private Sub PlaySong()
    If ListBox1.Items.Count > 0 Then
        If Player.playState = WMPLib.WMPPlayState.wmppsPaused Then
            Player.Ctlcontrols.play()
        Else
            Player.URL = TextBox1.Text & "\" & ListBox1.SelectedItem
            flag = True
        End If
    End If
End Sub

the same logic applies to the pause button. If state is pause then play the current song else pause the song.
Here is the code:

 Private Sub Pause_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Pause.Click
    If Player.playState = WMPLib.WMPPlayState.wmppsPaused Then
        Player.Ctlcontrols.play()
    Else
        Player.Ctlcontrols.pause()
    End If
End Sub

Hope it solve your problem

Sawamura commented: Lots answer huh.. Why don't you make repeat or shufle function too :) +4
Jx_Man 987 Nearly a Senior Poster Featured Poster

How far you go with this? Post your code.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Thanks mate! I have more questions stay tuned.

Don't forget to mark this thread as Solved.

More question? Just make new thread :)

Jx_Man 987 Nearly a Senior Poster Featured Poster

Look at line 7:
Result= Sale*0,04
It must be :
Result= Sale*0.04

Also Commition variable is not used. Just remove it.

ddanbe commented: Fine eye! +14
Jx_Man 987 Nearly a Senior Poster Featured Poster

Seems right.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Okay.. We need boolean variable here to handle what section now.

' Declare flag as global variable
Dim flag As Boolean = True

...


Private Sub PlaySong()
    AxWindowsMediaPlayer1.URL = TextBox1.Text & "\" & ListBox1.SelectedItem
    flag = True
End Sub

Private Sub NextSong()
   If flag = True Then
        If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsStopped Then
            ListBox1.SetSelected(ListBox1.SelectedIndex + 1, True)
            AxWindowsMediaPlayer1.URL = TextBox1.Text & "\" & ListBox1.SelectedItem
        End If
    End If
End Sub

Private Sub PlayButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PlayButton.Click
    PlaySong()
End Sub

Private Sub StopButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StopButton.Click
    flag = False
    AxWindowsMediaPlayer1.Ctlcontrols.stop()
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    NextSong()
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

Save the binary of image on accesss.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Use Select Statement.
e.g : "Select Holder_name, Balance from Account where Account_Number = '" & Textbox1.Text & "'"

ahudson commented: Thank You very much +0
Jx_Man 987 Nearly a Senior Poster Featured Poster

I have tried all posted code and works fine to me.
If you want to use timer then don't use playedstate event.
Also your if-then condition is different with my code above.
Read it carefully.
I prefer to use timer control to play next song.

Jx_Man 987 Nearly a Senior Poster Featured Poster

It's hard to do it if you don't know the exact time when the file is saved.
About this case, i think better to have form to manage backup files, so you can choose any backup files to be deleted.

Jx_Man 987 Nearly a Senior Poster Featured Poster

I fixed it

If you already fix it then please share with us the solution. Your answer will help another members who has same problem like you. Also make this thread as Solved.

Thank you.

Jx_Man 987 Nearly a Senior Poster Featured Poster

ListBox1.SetSelected(ListBox1.SelectedIndex + 1, True)
This line will set selected item on listbox with the index of item.
I use Listbox.SelectedIndex + 1 as a new index.
The current index of playing song is selected item, to get index of next item we need to add current index with 1.
Set as True to make the item with an index is selected.

More info about Listbox.SetSelected(index as Integer,value as Boolean)

Also you can use another approach to play next song.
You don't have to use PlayStateChange event of Windows Media Player but you can use timer control. Checking if song is ended and play next song.
Just add timer to form, set Enabled = True and Interval to 1.

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsStopped Then
        ListBox1.SetSelected(ListBox1.SelectedIndex + 1, True)
        AxWindowsMediaPlayer1.URL = TextBox1.Text & "\" & ListBox1.SelectedItem
    End If
End Sub

Hope it helps you to solve your problem.

Jx_Man 987 Nearly a Senior Poster Featured Poster

To play next song :

Private Sub AxWindowsMediaPlayer1_PlayStateChange(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_PlayStateChangeEvent) Handles AxWindowsMediaPlayer1.PlayStateChange
    If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsStopped Then
        ListBox1.SetSelected(ListBox1.SelectedIndex + 1, True)
        AxWindowsMediaPlayer1.URL = TextBox1.Text & "\" & ListBox1.SelectedItem
    End If
End Sub
Hazuan Nazri commented: Thanks! +0
Jx_Man 987 Nearly a Senior Poster Featured Poster

Sorry, I mean this line :
AxWindowsMediaPlayer1.URL = TextBox1.Text & "\" & ListBox1.SelectedItem

Hazuan Nazri commented: Nice!! Thanks! +1