1 Replies - 547 Views - Last Post: 04 June 2012 - 07:22 AM Rate Topic: -----

#1 Nightyeye  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 03-June 12

Need help on coding a "Data search engine" application

Posted 03 June 2012 - 09:21 PM

Hie,i'm having trouble coding a "Data search engine" for myself, i'm a beginner in VB .NET. Anyone who can help me solve my problem, a lot of thanks to you. so here's what my goal, i need help to make it search for all data files(.DAT) all in one shot,currently i managed to do it but it only search one by one, in this case i need to redo from the first step to search for another data files(.DAT). On the attachment,there's some example of data files(.DAT) i'm using.

Posted Image

I'm only able to do this far

Here's the code:
Dim lotno_data As String, dwg_data_array(3000) As String


Sub Search_lotno()
Dim Search_status As Integer, Total_rec As Integer


 Close #1
 Close #2
 'UserForm1.TextBox1.Visible = True
 On Error GoTo errhandle
 Title = "Select a Source file in Q:\*.dat"
 qfilename = Application.GetOpenFilename("Data Files (*.dat),*.dat,All Files(*.*),*.*", , Title)
 If qfilename = False Then
   MsgBox "No file was selected."
   Exit Sub
 End If
 
 Title = "Select a target file name(from drawing)"
 dwgfilename = Application.GetOpenFilename(, , Title)
 If dwgfilename = False Then
   MsgBox "No file was selected."
   Exit Sub
 End If
 
  Title = "Enter Output file name"
 outfilename = Application.GetSaveAsFilename("output.txt", , , Title)
 If outfilename = False Then
   MsgBox "No file was selected."
   Exit Sub
 End If
UserForm1.Hide

Open outfilename For Output As #3
 
 Open dwgfilename For Input As #2
 Worksheets(1).Select
 Worksheets(1).Range("E17").Value = "Searching in progress.........."
  
 Total_rec = 0
 i = 1
  Do While Not EOF(2)
   File1_counter = 0
   Line Input #2, dwg_data_array(i)
   i = i + 1
  Loop
  total2 = i - 1
   Close #1
   Open qfilename For Input As #1
   Do While Not EOF(1)
   lotno_data = ""
    Line Input #1, lotno_data
    a = Len(lotno_data)
    For j = 1 To total2
    Search_status = InStr(lotno_data, dwg_data_array(j))
     If Search_status > 0 Then
       a = 15 - Len(dwg_data_array(j))
       sperator_str = Space$(a) + "***"
       outstring = dwg_data_array(j) + sperator_str + lotno_data
       Print #3, outstring
       Total_rec = Total_rec + 1
       For k = j To (total2 - 1)
         dwg_data_array(k) = dwg_data_array(k + 1)
       Next
       total2 = total2 - 1
       Exit For
     End If
    Next
   If total2 = 0 Then Exit Do
  Loop

 
 Close #2
 Close #3

  Worksheets(1).Range("E17").Value = ""
 Total_str = Str(Total_rec)
 prompt = "Search completed,Total record found= " + Total_str
 MsgBox (prompt)
 UserForm1.Show
 Application.ActiveWorkbook.Save
 'Application.ActiveWorkbook.Close
 Exit Sub
errhandle:
  MsgBox Error(Err)
  Worksheets(1).Range("E17").Value = ""
  'Application.ActiveWorkbook.Save
  'Application.ActiveWorkbook.Close
  Exit Sub
End Sub
Sub Auto_Open()
UserForm1.Show
End Sub


Is This A Good Question/Topic? 0
  • +

Replies To: Need help on coding a "Data search engine" application

#2 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 550
  • View blog
  • Posts: 2,911
  • Joined: 19-May 09

Re: Need help on coding a "Data search engine" application

Posted 04 June 2012 - 07:22 AM

This isn't vb.net, this is vb6. So, you're in the right forum. Where did you copy this code from?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1