.Net Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - More.Net Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 3rd, 2012, 10:58 AM
nightyeye nightyeye is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 4 nightyeye User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 10 m 13 sec
Reputation Power: 0
Need help on VB .NET

Hie, I'm working for my project, it's a program to search for data. I just need some help to edit the code so that the program can search the data all in one shot..right now it only can search one by one and i need a lot of steps to do that, if i need to search for another data, i need to redo again from the first step. Please help me on this. By the way, is it possible if i make my .DAT files into a database using excel and connect it to the program? I'm using Visual Basic .NET

Here are the CODE:

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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - More.Net Development > How to make a Data Search Engine

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap