Jx_Man 987 Nearly a Senior Poster Featured Poster

Try :
playlist.Items.Add(TextBox1.Text & "\" & fileInFolder.Name)

Jx_Man 987 Nearly a Senior Poster Featured Poster

You mean that you want to open the form1 but it open form2? something like that?
You can remove the current form and add it back.

Jx_Man 987 Nearly a Senior Poster Featured Poster

but my problem is...it only displays the last record...why is that ?

Actualy, your code show the entire data but it will show you the last record because you use textbox to show it. Textbox value will replace with current record in looping and the end it will replace with last record.
If you change the line 10 with combobox (Combobox1.Items.Add (rdr("Stock")) then you will see the entire records.

But why you bind it again to database if you just want to display the selected item on listview?
Just use the code that i give to you above..
After you fill listview with data from database then use this following code to show selected item on listview.

Private Sub ListView1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.Click
    Dim x As Integer = CInt(ListView1.SelectedItems(0).Index)

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

You still do the same thing.
You do not include the form file.

Jx_Man 987 Nearly a Senior Poster Featured Poster

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

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

As i said before that we can't determine which file in position 4.
But the files always be arranged in ascending order by they name.

Say the number of files is 4 and you want to delete the file in postion 4 (the last file).
I try to put the files in listbox and accessing it by list index.

Private Sub Form_Load()

Dim strPath As String
Dim strFile As String
Dim FileCount As Integer

FileCount = 0
strPath = App.Path & "\backup\backup
strFile = Dir(strPath & "*.mdb")

Do Until strFile = ""
    FileCount = FileCount + 1
    List1.AddItem strPath & "\" & strFile
    strFile = Dir
Loop
MsgBox FileCount & " file(s)"
End Sub

Private Sub Command1_Click()
    Kill List1.List(List1.ListCount - 1)
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

How you named this file?
That codes just count how many .mdb files and we don't know which file in position #4.
Actualy the Dir Function will listed and arrange the file in ascending type and order by they name.

Jx_Man 987 Nearly a Senior Poster Featured Poster

I was give you the answer about getting items on listview in previous post.
How about post your update code?

Jx_Man 987 Nearly a Senior Poster Featured Poster

E.g : you want to count mdb files in your app.path folder

Dim strFile As String
Dim FileCount As Integer

FileCount = 0

strFile = Dir(App.Path & "*.mdb")

Do Until strFile = ""
    FileCount = FileCount + 1
    strFile = Dir
Loop
MsgBox FileCount & " file(s)"
Jx_Man 987 Nearly a Senior Poster Featured Poster

You can use this following code :

Private Sub Form_Load()
    If Dir$("D:\dani.txt", vbNormal) = "" Then
        MsgBox "This is your first time"
    Else
        ' Do anything if text file exist
    End If
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

Post your code. how far you doing this.

This following code to get items on listview and show it in textboxes

Private Sub ListView1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.Click
    Dim x As Integer = CInt(ListView1.SelectedItems(0).Index)

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

This backup files saved in one folder?

Jx_Man 987 Nearly a Senior Poster Featured Poster

I have tried that to but now it stops at line 18
with follow error path/file accsess error 75

It happen because when you press a cancel button there are no filename of text file to return.
Filename needed in line 18 to read the file.
So you must to handling it with check if there is no path from dialog box.

If strfileopen <> "" Then 'so this line will execute if path is available
    IntDemoFileNbr = FreeFile
    Open StrFileToOpen For Binary Access Read As #IntDemoFileNbr
    StrBuffer = Input(LOF(IntDemoFileNbr), IntDemoFileNbr)
    TxtTestFile.Text = StrBuffer

    Close #IntDemoFileNbr

    mstrLastDir = Left$(StrFileToOpen, InStrRev(StrFileToOpen, "\") - 1)
End If

also the use of On Error Go To statement is a bad thing.

Jx_Man 987 Nearly a Senior Poster Featured Poster

LeNenne,

If this thread is finish then please mark this thread as Solved.
It will help another members who has same problem like you.

Thank you

Jx_Man 987 Nearly a Senior Poster Featured Poster
.CancelError = True

In line 4, Set CancelError to False.

.CancelError = False
Jx_Man 987 Nearly a Senior Poster Featured Poster

e.g :

Private Sub Command1_Click()
    ' x^3 - 7x - 6 = 0 (ans : -2, -1 or 3)
    MsgBox realCubeRoot(1, 0, -7, -6, 0)
    MsgBox realCubeRoot(1, 0, -7, -6, 1)
    MsgBox realCubeRoot(1, 0, -7, -6, 2)

    ' x^3 - 5x^2 - 2x + 24 = 0 (ans : -2, 3 or 4)
    MsgBox realCubeRoot(1, -5, -2, 24, 0)
    MsgBox realCubeRoot(1, -5, -2, 24, 1)
    MsgBox realCubeRoot(1, -5, -2, 24, 2)

End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

In your qurey use "N" before your field value
e.g "insert into [UrduTextTable] values(N'" + txtUrduString + "')

Jx_Man 987 Nearly a Senior Poster Featured Poster

Add this lines :

FirstNameTF.AutoCompleteSource = AutoCompleteSource.CustomSource
LastNameTF.AutoCompleteSource = AutoCompleteSource.CustomSource
Jx_Man 987 Nearly a Senior Poster Featured Poster

In the properties of the MdiParent look for IsMdiContainer and set it to true.

Jx_Man 987 Nearly a Senior Poster Featured Poster

@ Lee

Hey man thanks alot for responding. I have decided to go another route on this project and am not sure of I can close this thread. But... I relized after I posted that I didnt need a 2D array. I am now takeing a very different route.

@administrators

you can close this thread. It was a poorly attempted question and only supports my claim at being new to programming.

Thanks for the help

Just mark this thread as solved.

Jx_Man 987 Nearly a Senior Poster Featured Poster

You're welcome.

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

This should working :

Private Sub Command1_Click()
For Each ctl In Me.Controls
    If TypeOf ctl Is CheckBox Then
        If ctl.Value = vbChecked Then
            MsgBox ctl.Name
        End If
    End If
Next
End Sub
Vixion commented: never think about this in my program. very useful function and svae my times. +0
Jx_Man 987 Nearly a Senior Poster Featured Poster

This is how to find the real roots using Newton’s method:

Function realCubeRoot(a, b, c, d, n)
    '
    ' computes the nth real root of the cubic equation
    '
    ' a x^3 + b x^2 + c x + d = 0
    '
    ' =================================================
    xold = 1
    iter = 0
    Do
        iter = iter + 1
        f = a * xold ^ 3 + b * xold ^ 2 + c * xold + d
        df = 3 * a * xold ^ 2 + 2 * b * xold + c
        xnew = xold - f / df
        Err = xnew - xold
        xold = xnew
    Loop While (iter < 1000) And (Abs(Err) > 0.000001)
    If n = 1 Then
        realCubeRoot = xnew
    Else
        aa = b / a
        bb = c / a
        Real = -(aa + xnew) / 2
        Disc = (-3 * xnew ^ 2 - 2 * aa * xnew + aa ^ 2 - 4 * bb)
        If Disc < -0.0000001 Then
            realCubeRoot = "NA"
        Else
            Disc = Abs(Disc)
            If n = 2 Then
                realCubeRoot = Real + Disc ^ (1 / 2) / 2
            Else
                realCubeRoot = Real - Disc ^ (1 / 2) / 2
            End If
        End If
    End If
End Function

Private Sub Command1_Click()
    MsgBox realCubeRoot(5, 2, 2, 4, 1)
End Sub
Estella commented: Helping as always. +4
Jx_Man 987 Nearly a Senior Poster Featured Poster

IRON MAN 3
HUMMINGBIRD

Jx_Man 987 Nearly a Senior Poster Featured Poster

Read this article and this article.

Hope it helps and solved your question.

Jx_Man 987 Nearly a Senior Poster Featured Poster

I want it in 4 columns (First name, last name, age and blood type).
There are 4 arrays that i want it to written in list view but the point is how i can read it form text file and use listview to show it.

This should working :

Private Sub Command1_Click()
Dim temp() As String

temp = Split(ReadFileText("D:\Mid Task\Data.txt"), vbNewLine)

With ListView1
    .View = lvwReport
    .FullRowSelect = True
    .ColumnHeaders.Add , , "First Name", 1100
    .ColumnHeaders.Add , , "Last Name", 1400
    .ColumnHeaders.Add , , "Age", 700
    .ColumnHeaders.Add , , "Blood Type", 1000


    With .ListItems
        .Clear
        For i = 0 To UBound(temp)
            temp2 = Split(temp(i), ";")

            Set lsvItem = .Add(, , temp2(0))
            lsvItem.SubItems(1) = temp2(1)
            lsvItem.SubItems(2) = temp2(2)
            lsvItem.SubItems(3) = temp2(3)

        Next i
    End With

End With

I think you don't have to use another arrays. Read data to temp array and write it to listview.

Hope it helps.

Sturdy commented: Thanks for the code +1
Jx_Man 987 Nearly a Senior Poster Featured Poster

Provide more information.
What you want to print?

Jx_Man 987 Nearly a Senior Poster Featured Poster

Welcome to daniweb larsquestion..

Please make your own thread. Don't rise dead thread.
You will get help from many members with new thread.

Thank you :)

Jx_Man 987 Nearly a Senior Poster Featured Poster

Try to set Combobox SelectionIndex = -1 to make it not select any items on Form Load event.

Combobox1.SelectionIndex = -1
Jx_Man 987 Nearly a Senior Poster Featured Poster

Try this :

Private Sub Form_Load()
    Dim Conn As New ADODB.Connection
    Dim rs As ADODB.Recordset

    Set Conn = New ADODB.Connection
    Conn.Provider = "Microsoft.ACE.OLEDB.12.0"
    Conn.CursorLocation = adUseClient
    Conn.Open "D:\database.accdb"

    Set rs = New ADODB.Recordset
    rs.Open "select * from mytable", Conn, adOpenDynamic, adLockBatchOptimistic

    While Not rs.EOF
        Combo1.AddItem rs!name
        rs.MoveNext
    Wend
    rs.Close

End Sub
imBaCodes commented: nice.. +3
Jx_Man 987 Nearly a Senior Poster Featured Poster

save the binary picture to the access database.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Or you can check if the textbox input is numeric using IsNumeric() function
Also read this snippet

Jx_Man 987 Nearly a Senior Poster Featured Poster

Not really understand what you want exactly.

Jx_Man 987 Nearly a Senior Poster Featured Poster

This is code already test and working fine.
I'm using keypress event just for textbox not for the button.
If you want to use button to play it then use button default event (click event) and don't change it with any events like keypress event.
Also please confirm that your textbox name is URLAddr and button name is Command1 to make this working.
I hope you can handle it.

Private Sub Command1_Click()
    Dim VideoAddr As String
    VideoAddr = Replace(URLAddr.Text, "/watch?v=", "/v/")
    WindowsMediaPlayer1.URL = VideoAddr 
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

You're welcome.

Jx_Man 987 Nearly a Senior Poster Featured Poster

I already build a program with vb6. The problem is when the program is running and user click the exe file again then it makes program running twice in same time.
Is there a way to restrict this happened?

Something like this should working :

Private Sub Form_Load()
    If App.PrevInstance = True Then
        MsgBox "Application is running!", vbExclamation, "Warning"
        End
    End If
End Sub
november_pooh commented: Very simple code but worked great!! +3
Jx_Man 987 Nearly a Senior Poster Featured Poster

how i can check if text box value exist in data base or not plzzz helppp

It's better to understand if you post your code. How far you doing this.

Jx_Man 987 Nearly a Senior Poster Featured Poster

See this example :

This is the xml file named student.xml :

<?xml version="1.0" standalone="yes"?>
<Table>
  <Students>
    <No>1</No>
    <Name>Jery</Name>
    <Address>New York</Address>
  </Students>
  <Students>
    <No>2</No>
    <Name>Dewi</Name>
    <Address>Olympus</Address>
  </Students>
  <Students>
    <No>3</No>
    <Name>Me</Name>
    <Address>earth</Address>
  </Students>
  <Students>
    <No>4</No>
    <Name>Craig</Name>
    <Address>Jogja</Address>
  </Students>
</Table>

This how to read and write it through datagridview :
Just add datagridview and button.

Imports System.Xml

Public Class Form1
    Dim ds As New DataSet
    Dim bs As New BindingSource
    Dim xFile As String = "student.xml"
    Dim flag As Boolean = False

    Private Sub ReadXML()
        ds.ReadXml(xFile)
        bs.DataSource = ds.Tables(0)
        DataGridView1.DataSource = bs
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If flag Then
            ds.WriteXml(xFile)
            flag = False
        End If
    End Sub

    Private Sub DataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
        Flag = True
        bs.ResetBindings(False)
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ReadXML()
    End Sub
End Class
Jx_Man 987 Nearly a Senior Poster Featured Poster

Is there away to do this in VB6

Yes. there's a way.

You must have Windows Media Player instaled in your computer.

First, add new component ( Windows Media Player)
You can press ctrl+T or Project->Add Component, then select Windows Media Player and press OK.
New component will added to your toolbox. Draw it to your form and also add Textbox to your form.

I'm Using Keypress event in textbox. After user input url in textbox and press enter then it will connecting.

Private Sub URLAddr_KeyPress(KeyAscii As Integer)
Dim VideoAddr As String

VideoAddr = Replace(URLAddr.Text, "/watch?v=", "/v/")

If KeyAscii = 13 Then
    WindowsMediaPlayer1.URL = VideoAddr 
End If
End Sub

This the snapshot :
2ae5ea38a4eb080a021177b50fceda34

Jx_Man 987 Nearly a Senior Poster Featured Poster

Try :

 Private Sub Command2_Click()
     Kill (App.Path & "\backup\PhoneTel.mdb")
 End Sub

Or you can do like this :

Private Sub filedelete(filename As String)
    Dim filesystemobject As Object
    Set filesystemobject = CreateObject("Scripting.filesystemobject")
    filesystemobject.deletefile filename, True
End Sub

Private Sub Command2_Click()
    filedelete (App.Path & "\backup\PhoneTel.mdb")
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

A positive attitude may not solve all your problems, but it will annoy enough people to make it worth the effort.

Jx_Man 987 Nearly a Senior Poster Featured Poster

First you must add the component. (ctrl+T or project->component) then select for Windows Media Player.
You will see new control and just add it to your form.
try this to play a video :

WindowsMediaPlayer1.openPlayer "D:\father.mp4"
Jx_Man 987 Nearly a Senior Poster Featured Poster

Wow..
How about make some effort here. We have rules in daniweb :)
Post your code and many members here trying to help you.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Glad to see that you've manage it.

Happy coding.

Jx_Man 987 Nearly a Senior Poster Featured Poster

dIndex = myText.IndexOf("|")
...
So, is there a "length" command to find the total number of characters in the string?

To get total character/length :

sLength = myText.Length

But if you want to get string after | sign then you can use substring function :

PrinterId = myText.Substring(myText.IndexOf("|") + 1)
Sawamura commented: +1 +4
Jx_Man 987 Nearly a Senior Poster Featured Poster

Something like this should working :

Function ReadFileText(ByVal filename As String) As String
        Dim handle As Integer

           ' ensure that the file exists
        If Len(Dir$(filename)) = 0 Then
            Err.Raise 53  ' File not found
        End If

           ' open in binary mode
        handle = FreeFile
        Open filename$ For Binary As #handle
           ' read the string and close the file
        ReadFileText = Space$(LOF(handle))
        Get #handle, , ReadFileText
        Close #handle
End Function

Private Sub Command1_Click()
Dim temp() As String
Dim temp2() As String
Dim FNArr() As String
Dim LNArr() As String
Dim AgeArr() As String
Dim BloddArr() As String

    ' split text file by new line (enter)
    temp = Split(ReadFileText("D:\Dani.txt"), vbNewLine)

    ' get how many rows in array
    x = UBound(temp) 

    ' redim each array with new rows. 
    ReDim FNArr(x)
    ReDim LNArr(x)
    ReDim AgeArr(x)
    ReDim BloddArr(x)

    For i = 0 To x
        ' split each line by semicolon sign
        temp2 = Split(temp(i), ";")

        ' write each data to proper arrays
        FNArr(i) = temp2(0)
        LNArr(i) = temp2(1)
        AgeArr(i) = temp2(2)
        BloddArr(i) = temp2(3)
    Next i

End Sub
Sturdy commented: Thanks for the great code sir. +1
Jx_Man 987 Nearly a Senior Poster Featured Poster

Well.. Datagrid is not the control with that purpose.
You can't do many things like write directly to datagrid.
You can use flexgrid instead of datagrid.

Jx_Man 987 Nearly a Senior Poster Featured Poster
while ((line = sr.ReadLine()) != null)
{
string[] values = line.Split(new string[] {","}, StringSplitOptions.None);
for (int i = 0; i < values.Length; i++)
{
.......
}

i dont know how to add values to the array

I'm little confused here.
Why you need to add value again to the array? You already read text file and store it into array named values.