CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2011

    Post comapre .xls and .csv in vb6

    can anyone help me with my project? i need to create a program where in i need to compare the invoice# in .xls and in .csv file. in the .xls there are 3 column (customer number, invoice#, date sent) and in .csv there are 10 columns (no header), the invoice# in .csv is located in 3rd column and the status of each invoice is in 2nd column. i need to compare and show the status of each invoice in the .xls file 5th column.

    (in .csv) if the status is 1 means accepted, 2- processed, 3- collected.

    i only started the interface where in i have 2 txt boxes (1st txt box for .xls and 2nd for .csv), and i added a command button so if i click this the process will start. i dont know how to start the main process, please help me. thanks a lot

  2. #2
    Join Date
    Jan 2006
    Fox Lake, IL

    Re: comapre .xls and .csv in vb6

    You'd have to read the XLS file, then get the cell needed. Reading the CSV is easier, though.

    Post the code that you have tried...

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008

    Re: comapre .xls and .csv in vb6

    As idicated above reading the XLS file can be tricky, especially so if you are not used to working with xls files. There are a couple of ways you can do this, one is to use Excel within your program but that will require the user to have Excel installed on thier system. The other is to use an ODBC data source to open the xls as a data fle which is the method I would consider. CSV can be done the same way but CSV is easy to work with directly in VB.

    Another option would be to save the xls file as a csv then you are dealing with 2 csv files and your work will be much easier.

    show us what you have so far.
    Always use [code][/code] tags when posting code.

  4. #4
    Join Date
    Jun 2011

    Re: comapre .xls and .csv in vb6

    thanks for the reply guys, below code were from different resources, and i dont know whats next after this... thank u very much for the help!

    Private Sub cmdBrowse1_Click()
    CommonDialog1.Filter = "Excel Files | *.xls"
    Text1.Text = CommonDialog1.FileName
    End Sub

    Private Sub cmdBrowse2_Click()
    CommonDialog1.Filter = "Comma Separated Values | *.csv"
    Text2.Text = CommonDialog1.FileName
    End Sub

    Private Sub cmdRun_Click()
    Dim strFilename As String
    Dim irow As Integer
    Dim value As Variant
    Dim xlApp As New Excel.Application
    Dim xlsheet As Excel.Worksheet
    Dim xlWrkBk As Excel.Workbook

    Set xlApp = New Excel.Application

    If Trim(Text1.Text) = "" Or Trim(Text2.Text) = "" Then
    MsgBox "Please select file for input!", vbExclamation, "Error"
    Exit Sub
    End If

    ExcelpathS = Trim(Text1.Text)
    ExcelpathS = Trim(Text2.Text)

    strFilename = GetFileName(ExcelpathS)

    Text1.Text = xlsheet.Cells(2, 1) ' row 2 col 1
    Text2.Text = xlsheet.Cells(2, 2) ' row 2 col 2

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.