 |
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1616
|
Re: Newbie Archived to Disk
You mean:
Dim str as String
str= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
' Does P exist in string?
If InStr(1, str, "P") > 0 Then
MsgBox "P Exists in the string."
End If
|
|
12-04-2002 at 07:19 PM |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1616
|
Re: Newbie Archived to Disk
Not the quickest way (which would be converting the file to a database - generally), but I think the following may be closer to what you're looking for:
Option Explicit
Private Sub FindStuff()
' Would require a text box named txtSearch
Dim Free As Integer
Dim astr() As String
Dim tmp As String
Free = FreeFile
ReDim astr(0)
Open "Filename.ext" For Input As Free
Do
DoEvents
Line Input #Free, tmp
If InStr(1, tmp, txtSearch.Text) > 0 Then
astr(UBound(astr())) = tmp
ReDim Preserve astr(UBound(astr()) + 1)
End If
Loop Until EOF(Free)
End Sub
|
|
12-04-2002 at 08:31 PM |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1616
|
Re: Newbie Archived to Disk
Opening the text file as a database would look like the following:
Private Sub DBFindStuff()
Dim adc As New ADODB.Connection
Dim ars As New ADODB.Recordset
Dim PathtoTextFile As String
Set adc = New ADODB.Connection
Set ars = New ADODB.Recordset
PathtoTextFile = App.Path & "\" 'end with terminating slash
adc.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & PathtoTextFile & ";" & _
"Extended Properties=""text;HDR=YES;FMT=Delimited"""
ars.Open "SELECT * FROM Data.txt", adc, adOpenStatic, adLockReadOnly
' NOTE: the first line in the text file will be the field names
If Not ars.BOF And Not ars.EOF Then
ars.Filter = "F1='P' or F2='P' or F3='P'"
MsgBox ars.RecordCount ' number of records where filter is true
End If
If ars.State = adStateOpen Then ars.Close
If adc.State = adStateOpen Then adc.Close
Set ars = Nothing
Set adc = Nothing
End Sub
Text File "Data.txt" contains:
F1,F2,F3
1,2,3
a,b,c
d,e,f
g,h,i
j,k,l
m,n,o
p,q,r
q,r,p
r,p,q
4,5,6
7,8,9
|
|
12-04-2002 at 08:54 PM |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1616
|
Re: Newbie Archived to Disk
You're welcome.
Visual basic does have some access controls built into it, so you do not have to have access to open or create access databases. But given your situation, you may not want to do it, even if it would greatly increase the programs performance.
|
|
12-04-2002 at 09:29 PM |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1616
|
Re: Newbie Archived to Disk
I'll be getting the .NET version. I'd basically say, get to know version 6, and .NET if possible. Basically depends on whether you wish to do professional programming.
If companies decide to use the .NET version, then they'll probably need people to either 1) maintain the VB6 code, or 2) convert the VB6 to .NET.
If you have the money, get the .NET. Some things are similar, so if you know the .NET, you'll still be using some VB6 stuff (but not the same way, or as easy though).
|
|
12-04-2002 at 09:54 PM |
|
|
|
|
 |
 |