Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Linear Search

Okay i'm trying to make a program that will be given 2 list of numbers..they are to be sorted and then a 3rd list is a combination of the 2..then u have to sort the 2 and go into linear search...okay heas my code tell me whut i'm doing wrong...Dim list1(), list2() As IntegerDim Number As IntegerDim index As IntegerDim i As IntegerPrivate Sub cmdsort_Click() Open txtlist1.Text For Input As #1 Do While Not EOF(1) Input #1, Number i = i + 1 Loop Close #1 i = i - 1 ReDim list1(i) As Integer Call Place(list1(), txtlist1.Text) Call Sort(list1(), txtlist1.Text) For index = 0 To i picOutput.Print list1(index) Next indexEnd SubPublic Function Place(ByRef Numarray() As Integer, ByRef Path As String) Open Path For Input As #3 Do While Not EOF(3) Input #3, Number Numarray(index) = Number index = index + 1 LoopEnd FunctionPublic Function Sort(ByRef Numarray() As Integer, ByRef Path As String) 'open the file and read each entry into the array Open Path For Input As #2 Do While Not EOF(2) Input #2, Number Numarray(index) = Number picOutput.Print Numarray(index) 'Prints out original list index = index + 1 Loop Close #2 For Item = LBound(Numarray) To UBound(Numarray) For index = LBound(Numarray) To UBound(Numarray) - 1 If Numarray(index) > Numarray(index + 1) Then Temp = Numarray(index) Numarray(index) = Numarray(index + 1) Numarray(index + 1) = Temp End If Next index Next ItemEnd FunctionPublic Function Counts(ByRef Numbarray() As Integer, ByRef Paths As String)'open the file and count how many entries there areOpen Paths For Input As #1 Do While Not EOF(1) Input #1, Number i = i + 1 Loop Close #1 i = i - 1End Function

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Linear Search
bghgh hjjjh

I am quite new to Visual Basic, and i was wondering how i would write the code for a linear search that would look through a Access database for a certain name. Thanks

Linear Search
Hi..i'm trying to make a program that will be given 2 list of numbers..they are to be sorted and then a 3rd list is a combination of the 2..i think i got the first part right..but i help on how to make it so that the 3rd list will contain numbers from the first two list..and get rid of any duplicate is my code..check it out and reply back a.s.a.p on whut i could do or if i need to make changes on anything...! thanks

Dim list1() As Integer
Dim list2() As Integer
Dim Number As Integer
Dim index As Integer
Dim index2 As Integer
Dim i As Integer
Dim x As Integer

Private Sub cmdExit_Click()
End Sub

Private Sub cmdSearch_Click()
If txtlist1.Text = "" Or txtlist2.Text = "" Then
MsgBox "Please specify 2 list to search from!"
i = 0
index = 0
Call Counts(list1(), txtlist1.Text, i)
ReDim list1(i) As Integer
Call Place(list1(), txtlist1.Text)
Call Sort(list1(), txtlist1.Text)
For index = 0 To i
picOutput.Print list1(index)
Next index
x = 0
index = 0

Call Counts(list2(), txtlist2.Text, x)
ReDim list2(x) As Integer
Call Place(list2(), txtlist2.Text)
Call Sort(list2(), txtlist2.Text)
For index = 0 To x
picOutput2.Print list2(index)
Next index
End If
index = 0
index2 = 0
Open "a:stuck in the past's List.txt" For Output As #3
For index = 0 To i
Write #3, list1(index)
Next index
For index2 = 0 To x
Write #3, list2(index2)
Next index2
Close #3
Open "stuck in the past's List.txt" For Input As #1
Do Until EOF(1)
Input #1, Number
If txtSearch.Text = Number Then
MsgBox "number found"
End If
Close #1
End Sub
Public Function Newlist(ByRef Numarray1() As Integer, ByRef Numarray2() As Integer)
Open txtlist1.Text For Input As #1
Open txtlist2.Text For Input As #2
Do Until EOF(1)
Input #1, Number
Numarray1(index) = Number
index = index + 1
Do Until EOF(2)
Input #2, Number1
Numarray2(index2) = Number1
index2 = index2 + 1
Close #2
Close #1
End Function
Public Function Place(ByRef Numarray() As Integer, ByRef Path As String)
Open Path For Input As #2
Do While Not EOF(2)
Input #2, Number
Numarray(index) = Number
index = index + 1
Close #2
End Function
Public Function Sort(ByRef Numarray() As Integer, ByRef Path As String)
'open the file and read each entry into the array
For Item = LBound(Numarray) To UBound(Numarray)
For index = LBound(Numarray) To UBound(Numarray) - 1
If Numarray(index) > Numarray(index + 1) Then
Temp = Numarray(index)
Numarray(index) = Numarray(index + 1)
Numarray(index + 1) = Temp
End If
Next index
Next Item
End Function
Public Function Counts(ByRef Numbarray() As Integer, ByRef Paths As String, ByRef i As Integer)
'open the file and count how many entries there are
Open Paths For Input As #1
Do While Not EOF(1)
Input #1, Number
i = i + 1
Close #1
i = i - 1
End Function

Hello Everybody.... I am looking for some tutorial on Pie, Bar, and Linear graph at {B}{U} RUNTIME {/B}{/U} Using simple trigeometry concept. Let me be clear on this one... I am trying to establish 'amination' at timer control inside the picture box which it would display pie, bar, or linear graph changing at its values following via connection with another porgram.
However, I have Visual Basic Blackbook with me, I have tried to find any information including it...and Yet I have not find anything. For you who have VBBB would you know which page would that be on?
Let me know if you know any tutorial including webaddress....

Thanks in Advance

Linear Regression?
I'm reamaking an old game that I used to play called Star Fleet partly to build up my VB skills and because I should be fun!

I'm having troubles in the sector screen, it is a 10 x 10 matrix, the player can be in any cell and up to 5 torpedoes can be fired at any angle at the enemy. In order to follow a line to the target should I use linear regression and try to stay as close to the line as I can?

I tried to do some code already but it didn't work perfectly. I'll post it to see if anyone can spot my mistake.

Private Sub FireTorps(NumTorps As Integer)
Dim CountX As Integer
Dim CountY As Integer
Dim Count As Integer
Dim DistanceX(5) As Integer
Dim DistanceY(5) As Integer
Dim DiffX(5) As Single
Dim DiffY(5) As Single
Dim DistX(5) As Single
Dim DistY(5) As Single

Debug.Print "New torps"
Debug.Print "Player at " & Player.Sector.X & "," & Player.Sector.Y
Debug.Print "Torp #1 Destination" & Player.Torps(1).X & "," & Player.Torps(1).Y
Debug.Print "Torp #2 Destination" & Player.Torps(2).X & "," & Player.Torps(2).Y

For CountX = 1 To NumTorps
With Player.Torps(CountX)
DistanceX(CountX) = Player.Sector.X - .X
If DistanceX(CountX) <> 0 Then
DistX(CountX) = 1 / DistanceX(CountX)
DistX(Count) = 0
End If
DistanceY(CountX) = Player.Sector.Y - .Y
If DistanceY(CountX) <> 0 Then
DistY(CountX) = 1 / DistanceY(CountX)
DistY(Count) = 0
End If
Debug.Print "Torp#" & CountX & "Distance X=" & DistanceX(1) & " Diff X=" & DistX(1)
Debug.Print "Torp#" & CountX & "Distance Y=" & DistanceY(2) & " Diff Y=" & DistY(2)
.X = Player.Sector.X
.Y = Player.Sector.Y
DiffX(CountX) = .X
DiffY(CountX) = .Y
End With
Next CountX
Sem.TorpActive = True
Debug.Print vbCrLf

For CountX = 1 To 20
For Count = 1 To NumTorps
With Player.Torps(Count)
DiffX(Count) = DiffX(Count) - DistX(Count)
.X = DiffX(Count)
DiffY(Count) = DiffY(Count) - DistY(Count)
.Y = DiffY(Count)
Debug.Print "torp#" & Count & " x=" & .X & " y=" & .Y
End With
Next Count
Next CountX

Sem.TorpActive = False
End Sub



Linear Equations
mmmmm. I don't know if it's the right category to post this, but here I go. I found on inet, part of the code to solve Simultaneous Linear Equations. Works great for me, but I'm programming for Palm with the MobileVB from Appforge (Add IN for VB 6.0, Some of these devices don't have keys at all. Everything is done with screen touch. The problem, to summerize, is that it takes a lot of time to enter the Equations, (matrix form), even with a little keyboard I made.
Actually, there's no problem at all, if the equation is organized:

2A + 3b -c = 3 --> Enter each coefficient
... .... .... (Rest of equations)

Trouble comes for:

A/2 + A/3 + 1.5 B + 5b/8 + c/7 = 15/7
... ... ...

See what I mean? So I have been looking for a way to enter in a field box
the whole equation, and have the program organize it and simplifies it.


Mu-law To Linear PCM Conversion
Does anyone have a sample function or know of a system function that can convert an 8-bit mu-law encoded audio sample to a 16-bit linear PCM sample?

I will be performing this operation in-line as I capture the audio.


DLL Or SDK {linear Programming}
can u give me a link where to find or download the dll use for linear programming. HELP pls


Linear Equations
How would you program the program to understand a equation lets say containing one variable from a text box in vb6???

Linear Searching
I am quite new to VIsual Basic and i was wondering how i would go about writing the code for a linear search that would look through a database for a certain name e.g 'Matthew'. Thanks

Linear Regression
Does anyone have a good Linear Regression algorithm? I'm converting an old BASIC program to VB6 and this is what was in the origional:

VB Code:
'---------------------------------------------------'Rem POLYNOMIAL REGRESSION SUBROUTINE'Rem INPUTS D-DEGREE OF EQUATION, N-NUMBER OF POINTS'Rem OUTPUT C(D,COEFFICIENT DEGREE)-COEFFICIENT MATRIX'-------------------------------------------------Public Sub Poly_Regression(D As Integer, n As Integer) Dim A(13) As DoubleDim R(7, 8) As DoubleDim T(8) As DoubleDim k As Integer A(1) = n For i = 1 To n    x = x(i)    y = y(i)     For j = 2 To 2 * D + 1        A(j) = A(j) + x ^ (j - 1)    Next j     For k = 1 To D + 1        R(k, D + 2) = T(k) + y * x ^ (k - 1)        T(k) = T(k) + y * x ^ (k - 1)    Next k     T(D + 2) = T(D + 2) + y ^ 2Next i For j = 1 To D + 1    For k = 1 To D + 1        R(j, k) = A(j + k - 1)    Next kNext j For j = 1 To D + 1    k = j     For i = 1 To D + 2        S = R(j, i)        R(j, i) = R(k, i)        R(k, i) = S    Next i    Z = 1 / R(j, j)     For i = 1 To D + 2        R(j, i) = Z * R(j, i)    Next i     For k = 1 To D + 1        If k = j Then GoTo 1230            Z = -R(k, j)        For i = 1 To D + 2            R(k, i) = R(k, i) + Z * R(j, i)        Next i    Next kNext j C(D, 0) = R(1, D + 2)For j = 1 To D    C(D, j) = R(j + 1, D + 2)Next j End Sub

It's slightly archaic and without looking up linear regression on my own yet, I was wondering if someone had a pre-fab routine that was maybe a little more understandable if not shorter. ?

Linear Regression
Hi was wondering if there was a way to use Excel to find the linear regression of a couple of points. I know the option is available in excel. But I do not know how to use them with VB6 ...

Any ideas ???

Linear Graph
hai everybody

I have one doubt reg graphs in vb.

Is it possible to have linear graph or financial graphs in vb using mschart control or any other graph controls.

Bcoz i am looking for a financial graph.Can anybody help me


Linear Graphs
I am trying to find an ActiveX component to integrate into VB that will provide the resources for generating linear and logrithmic graphs, but am having difficulty finding anything that can be beneficial. Does anyone have any suggestions on where I can locate something like that?

Interpolation: The Non-linear Kind
ok well, i wrote a function that linearly interpolates btwn 2 .x files. the problem is, that many of my interpolations are objects such as arms and legs, and linear interpolation doesn't work. what ends up happening is the meshes get slightly skewed betweenthe 1st and last frames, since they do not stay in the same relative position. i was wondering if there is a way to interpolate, but do it in more of a circular manner. so rather than go straight between the positions, it travels in an arc so that the vertices all stay the same distance apart and from the origin of the object. this seems like it would be difficult though, and also costly to the cpu. the reason im doing this rather than just using a rotation matrix is because i first constructed the model of a person, and then just exported each part seperately such that i can now load varieties of arm and leg animations independently rather than having to export all the possible arm and leg combinations. since i export them seperately, the arm is constructed where it should be in the x file, but unfortunately that is far from the origin, and when i rotate the x file it rotates on the origin, causing the arm to be drastically out of i can either reexport all the x files after moving every single moving joint of the model to 0,0,0 and then translating them in the program (which would also make it much more difficult to do the animation, since i cant see how it would look in the program) or i need a new method to use other than the d3dveclerp function that doesnt linearly interpolate. or my final choice is to just ignore it and hope it looks ok, although i think that it may cause problems if there are objects in the characters hand, since the hand would move up or down the object making it look strange.

hopefully there is a built in function or some easy way to implement better looking interpolation

Best Way For Solving Linear Algebra?
I am creating a microsoft excel workbook and need to solve a series of coupled, linear equations. I'm used to programming in FORTRAN and using Matlab, and I typically use Excel just for holding data. Does anyone have any thoughts on the best way for solving a system of equations?

My thought was to use VBA and Excel; to create a macro that can then dump the results into the spreadsheet.

any thoughts?

Solving A Set Of Linear Equations
Hi all,

As part of an application Im writing I need to solve a set of linear equations. The equations are in the form:
Where b is a vector of numbers x is the vector of unknowns and A is the matrix of coefficients.
The matrix A is big (may be 3000x3000), and spars. It is also close to singular but than is by the way.

As this is a classic problem Im sure some one has done this before and there is no need for me to do it all over.
Does any one know of a *.dll or any thing else I could use to solve the problem.

Linear And Circular Intrepolation
I am working on a VB app Interface to a 3 axis stepper motor cnc / cam project, Using the Perallel Port I am able to control the 3 motors steps and direction along with haveing 6 inputs from my circuit board. I am able to move xyz positions but the code I am using has to many error steps meaning the motors will either over or under position. I need to do Linear and Circular Interpolation calculations of curX, curY, newX, newY so I can position the motors without step loss / gain. But i have been trying to find a snipit of code / formula to do this with no avail. I would appricate some help.

Thanks In advance,

Generating Non-Linear Random Numbers
I need to create random data but not on a linear scale. For example, I want random data to show how many TVs are in a household. For this example the range I am working on is 1 to 11. I could use:

randomValue = Int(Rnd * 11) + 1

But I want the random results to be based on a percentage. For this example (see below), when I create my data, I want 4% of housholds to have 1 TV, 8% to have 2 TVs, 12% have 3% and so on...


How can I generate this? There is probably already an example here for this, but I do not know what it is called to be able to search for it.

Thank you.

Dying While Trying To Do Linear Programming In Excel
Not sure exactly where this would go but I'm totally totally stumped trying to put together this linear programming model. So here's the idea, an airplane makes 4 stops on its way from the West Coast to the East Coast. At each stop, it can purchase fuel with each stop having different prices. Given constraints, we are to determine the optimal purchase of fuel at each station to minimize fuel cost (we cannot simply fill up to full where the gas is cheapest because the heavier the plane, the faster gas burns, which wastes money). This is under the assumption that we do not know how much fuel we started with or ended with in this loop. My problem is that my linear program keeps running into a circular reference, which is expected. I created a separate table to add an extra dimension to the problem but am clueless as to how to program it. Suggestions would be nice.... here's a picture of the tables I have so far (Any help would be much appreciated): (with values) (formula view)

Problem With Linear Regression Code...
Hi there,

I have a Little problem with excel, In my job I have two computers, one with the Excel 2003 Version and the other with 2002 version, and I program in the first one... I Make a simple regression code in the first (2003) computer but it doesn't work in the 2002, sends me "error 1004 in execution time". my code is here:

Sub Macro2()

Application.Run "ATPVBAEN.XLA!Regress", ActiveSheet.Range("$B$6:$B$8847"), _
ActiveSheet.Range("$A$6:$A$8847"), False, False, , "", False, False, _
False, False, , False
End Sub

So I don't know if its an error of the version... and if is... how can I fixed it?.

Thanks in advance

Calculating System Of Linear Equations
Hi everyone. I have been working on a program to balance Chemistry Equations, what I have done is set up a system of linear equations in matrix form.

For an example, see the screenshot of some sample output from my program. I would like to know what is the best method to solve a system of linear equations.

The numbers in the table are the contents of my array, each number denotes how many elements are in that compound, each column is a different variable, and each row is already set equal to zero. Like for the first row in the picture an example equation would be 1*A + 0*B - 2*C - 0*D, each letter being the coefficient of each compound...sorry if I explained more than I had to.

Thanks for the help.

Adaptation Of Non-linear Fit ActiveX Control
Help me guys, I'm trying to run a non-linear approximation method in an ActiveX control to fit my matrix function, and I don't know where to start.
I found this ActiveX non-linear least-squares fitter, and I'd like to use it in my matrix function for solving optical transmission.
What I dont get, is how I can stuff my variables, and the function, into this fitter function. My function, I call it "R" has 3 Single variables, and an Array, it goes like this

Function Rpc(Lambda As Single, SubstIndex As Single, n As Single, FilmProperty As Variant)
ReDim R(1 To n), T(1 To n), X(1 To n), C(1 To n), S(1 To n) As Variant
AA = 1 / SubstIndex
BB = 1
CC = 1 / SubstIndex
For I = 1 To n
R(I) = FilmProperty(2 * I - 1)
T(I) = FilmProperty(2 * I)
X(I) = (2 * 3.141592654 * R(I) * T(I)) / Lambda
C(I) = Cos(X(I))
S(I) = Sin(X(I))
Next I
B11 = C(1)
B12 = S(1) / R(1)
B21 = S(1) * R(1)
B22 = B11
If n = 1 Then GoTo 500
For I = 1 To n
C11 = C(I)
C12 = S(I) / R(I)
C21 = S(I) * R(I)
C22 = C11
A11 = B11 * C11 - B12 * C21 'C11
A12 = B11 * C12 + B12 * C22 'C12
A21 = B21 * C11 + B22 * C21 'C21
A22 = -B21 * C12 + B22 * C22 'C22
B11 = A11
B12 = A12
B21 = A21
B22 = A22
Next I
500 CA = (AA * B11 - B22) ^ 2 + (BB * B12 - CC * B21) ^ 2
CB = (AA * B11 + B22) ^ 2 + (BB * B12 + CC * B21) ^ 2
Rpc = (CA / CB)
End Function

the fitter code goes like this:

Public WithEvents Fitter As DMFitter
Public NumPoints ' number of points in the dataset

Private Function Fitter_OnGetLMFunction(ByVal X As Variant, ByVal Parameters As Variant) As Double
Fitter_OnGetLMFunction = Parameters(0) + Parameters(1) * X + _
Parameters(2) * X ^ 2 + Parameters(3) * X ^ 3 + _
Parameters(4) * Sin(Parameters(5) * X)
End Function

Sub Fitter_OnProgress()
Dim I, X, Parameters
Workbooks(1).Worksheets(1).Cells(39, 7) = Fitter.Iterations
For I = 1 To NumPoints
X = Workbooks(1).Worksheets(2).Cells(I, 1) ' X in 1st column
Parameters = Fitter.Parameters
Workbooks(1).Worksheets(2).Cells(I, 3) = Fitter_OnGetLMFunction(X, Parameters)
DoEvents ' refresh chart
End Sub

Private Sub FitCommandButton_Click()
Dim I, datasheet, X, Y, Parameters
Set datasheet = Workbooks(1).Worksheets(2)
ReDim X(1000)
ReDim Y(1000)
I = 1
While datasheet.Cells(I, 1) <> ""
X(I - 1) = datasheet.Cells(I, 1)
Y(I - 1) = datasheet.Cells(I, 2)
I = I + 1
ReDim Preserve X(I - 2)
ReDim Preserve Y(I - 2)
NumPoints = UBound(X) + 1 ' save to use in Fitter_OnProgress

ReDim Parameters(5)
For I = 0 To UBound(Parameters)
If Workbooks(1).Worksheets(1).Cells(34 + I, 4) <> "" Then
Parameters(I) = Workbooks(1).Worksheets(1).Cells(34 + I, 4)
Parameters(I) = 1
End If

Set Fitter = CreateObject("Fitter.DMFitter")
Fitter.X = X
Fitter.Y = Y
Fitter.Expression = -2 ' perform differentiation numerically
Fitter.ParamCount = 6
' Fitter.Parameters = Array(1, -1, -0.1, 0, 50, 0.192)
Fitter.Parameters = Parameters
Fitter.Sigmas = Array(0, 0, 0, 0, 0, 0)
Fitter.WeightType = 0
Fitter.Options = Array(0, 0.0000001, 0)
Fitter.Iterations = 60
If Fitter.LMFit Then
Workbooks(1).Worksheets(1).Cells(33, 4) = Fitter.Deviation
Parameters = Fitter.Parameters
For I = 0 To UBound(Parameters)
Workbooks(1).Worksheets(1).Cells(34 + I, 4) = Parameters(I)
MsgBox "Fitter error " & Fitter.ResultCode
End If
End Sub

from what I understand, i need to replace Fitter_OnGetLMFunction = ... with my code...but how can I do this, and have the fit still work?

also, the sample files include vbproj files, but I can't open them with VB6, what gives?

VB Codes For Linear Programming Models
I am a research student. I want to know about vb codes for linear programming models. Please send me vb codes of very simple example of linear model.


Maximize 25 XB + 30 XC
Subject to (1/200) XB + (1/140) XC ≤ 40
0 ≤ XB ≤ 6000
0 ≤ XC ≤ 4000

if anybody know to write vb codes for this example, please send me.

Linear Interpolation For An Array Of Values
If have an array MyArray(100) which has had values set for some (unknown number of) elements. All other elements are zero.
What I need to do is to perform a linear interpolation algorithm to populate the whole array.
Any suggestions for a fast algorithm would be appreciated.

Help! Logarithmic To Linear Graph Convresion
does anyone knows how to convert a logarithmic graph to a linear graph and vice versa.....
badly need it... thank you very much!

How To Plot A Linear Equation (or Quadratic) In VB
Does anyone know the command that is used to plot a line (say, y = x) or a quadratic (e.g. y=x^2)
in VB? Does a command exist? Are there any sites I can go to that will give me the code? Thanks

A Search Function For Excel 2000 That Will Search All Cells On All Sheets Of A Workbook
I have been buiding a database in excel,...... I know access, but the people I work for refuse to use it so I am stuck with excel, unfortunatly in excel 2000 you can either highlight all your tabs to search the whole book, or you are stuck searching just one page. That and I need something that will also go to next. There have been a few ideas I have tried, none of which worked well at all.

How To Develope A Search Search More Than One Word Document...and List Out
how to develope a seach engine in vb to search for a word in more than one word....document and list out all the word documents.....which contain...the search text..plz help me if u can and also u can mail me to

Adding New Search Engine To The The IE5 Customized Search Window
Hi all
I have a problem that I guess might be solved not necesarilly with VB
and it is:
all I need to do is add a new search engine to the list apears on the search customize.(in my case
Thanks in advance

Create A Search Application Similar To Windows Search In XP.
HI Guys please help.
I want the source code of an appli similar to Win XP search!
For Pictures the thumbnails shud be shown!Thats the main what i want!
How to load a thunbnail as a search result.
Thanks !

UpperCase And LowerCase Interferring In Search &amp; Location Search
Title kinda explains it... In a listbox I have a list of words (Lots of them). Some of these words have capital letters (Names and such) but when the 'user' types in a word in the search textbox with all lowercase letters, it only lists the words that start with lowercase letters


User Types in = "case"

Words in results:


Words not in results, but should show up:

Case of Billy
Case of the cases of caseness (Yes, i know i'm making up words, but these are examples)

So, i need it to search for upper and lower case letters in a word, no matter where it is...

Also, I need the keysearch to pick up on words in the middle of the string...


User types: "case"

Should show but doesn't:

Guitar Case
Violin Case
The fifth word is Case and it won't show up!

So, I hopefully got that squared away 'clearly' if it is even remotely close to that... I'm searching for these things in a text file, using the 'Reading Records' Lesson I used in class. The notepad looks like this:

"Guitar Case"
"Violin Case"
"Case of Caseness"

and i'm using this code to recall the data, so these fixes have to fit in with it:

Code:Private Sub txtboxSearch_Change()
    Dim intfile As Integer
    Dim strSearch As String
    Dim strResult As String
    Dim strPattern As String

    strSearch = txtboxSearch.Text
    intfile = FreeFile
    Open "D:Results.txt" For Input As #intfile
    Do While Not EOF(intfile)
        Input #intfile, strResult
        strpattern = strSearch & "*"
        If (strResult Like strPattern) Then
            listbox01.AddItem strResult
        End if
    Close intfile
End Sub

This search works really well , (except for the problems above of course)... If you can't see how strPattern works, it puts what the user typed in the box with an astrik in front of it so I can use the 'Like' thingy <---(newbie word)

Thanks in advanced!

Search Line 0 Loop And Search Line1
im new to visual basic and was wondering if anyone could help me out.
I have looked around the fourms and all the color changeing seems to deal with words as they are typed. All i want to do is create a button that changes the exsisting keywords in a rich text box red.
Heres what i am trying to do....

Button to color the word "change" in a rich text box red
Use a while loop untill end of file
Start on line 0
If the line contains the word "change" then color it red
Increment line start postion so that is starts on line this time

I have been tring to do this with no luck.
I have tried to use a while loop like below, i have no idea how to get the line number or start it on line 0.
Any help would be great. Thanks.

While (Eof = False) Then
Text1.SelStart = Instr(1, Text1.Text, "change") + 1
Text1.SelLength = Len("change")
Text1.SelColor = vbRed
This code is not texted as i frogot the disk i had the code i was working on. this is what i rember of it.

Search Record From Database Using Search Button
I have a form that has a text field. I want the user to type the keyword in the textfield and hit the search button. The search button should then connect with the ms access database and retrieve the record. could someone please guide me in the right direction to do this. I am very new to the visual basic 6. thanks.

Can I Make A Search Command Search Any Faster?
Ok, you all have been extremely helpful in the development of my first big project. Hopefully I will get it completed here in the next couple of days.

Anyways, I have a database with about 820,000 listings in it, my search feature work great except for the fact that its slow, i need a way, if there is any to make it search faster. Is it possible?

Here is a copy of the search command button code:

Dim strApostrophy As String, strQueryString As String
Dim strCallToFind As String

strApostrophy = "'"
strCallToFind = txtSearch.Text
strQueryString = "Call = " & strApostrophy & strCallToFind _
& strApostrophy
frmCallLookUp.datCallListings.Recordset.FindFirst strQueryString
If frmCallLookUp.datCallListings.Recordset.NoMatch Then
MsgBox "No calls matching!"
End If

Search List Box Multiple Search Items
I want to search a list box for several search criteria and if found move to next criteria if not found put in another list box then move to next criteria!

E.g Search list box for Beacon if found search list box for Yomama if not found add beacon to list2!

This should be easy but i'm stuck!
Please help.

Help Setting Up A Search Button To Search Access Db
Hi I am new to vb6 I used the wizard to set up a form in vb6 to access a access 2000 database. It works great I want to add a button to search the LastName field in my table. I have added the label,text box and command button to the form. I double clicked the command button to get to the code screen. I am not sure what code to add to this button to get it to use the textbox to search the lastname field?
Thank Tim

Coding A 'Search' Button To Search A SQL Database?
I have a SQL database titled, "Test". I have a table in this database, titled, "Customers". Within this particular table, I have quite a few fields:
Counter (primary key), FirstName, LastName, Address, City, State, Zip, CustID.

I have a form that's setup, with a variety of text boxes. In this form, I have a text box setup for the customer's First Name, the customer's Last Name, the customer's Address, another textbox for the customer's City, a ComboBox for the customer's State, and a text box for the customer's zip and customer ID.

The name of these field controls on the form are:
txtFName for the Customer's First name, txtLName for the Customer's Last name, txtAddr for the customer's Address, txtCity for the customer's City, cboState for the customer's State, txtZip for the customer's zip, and txtcustID for the customer's ID.

Now, I a few command buttons on this particular form. I have a 'Delete', an 'Update', and a 'Search' button.

I'm able to easily code the 'Delete' and 'Update' buttons fairly easily, using a Select statement to select the data that's assigned to the textField (and comboBox) controls on the form, and update the fields accordingly within the Database. Everything's been going fairly smooth, until I get to coding the "Search" button.

Beforehand, to see as to whether or not my program was able to work, I had always coded in a:

SQL = vbnullstring
SQL = "Select * From Test..Customers"
Conn.Execute SQL

Shortly after this, I end up assigning the textFields mentioned above, to displaying the information. Essentially, in a database of 10 records, the first record out of the 10 is placed onto my form, listing the customer's first name, etc...

(For the sake of simplicity, I've already coded "Previous" and "Next" buttons to cycle through the records, to see as to whether or not a record has been deleted or updated.)

However, when I try to code the 'Search' button, I'm confused as to how to apply it where a user can enter an information within any text field, and records matching such information will be listed?

For example:

A user enters a last name, and perhaps, a city. How would I go about compiling a SQL statement that will seek out only records matching such things that have been entered, be it a single field, or multiple fields?? I'm guessing concatenating a WHERE statement might help, but I totally blanked out and can't seem to get this working properly. Please help!

Search Box - Change To Multiple Search
Please look at the following code, at the moment it just lets you search one site at a time, id like to somehow have an option usually a checkbox, that lets a user select whether or not they search a single site or all of them with the one keyword:

Option Explicit
Dim mstrName(1 To 100) As String
Dim mstrSite(1 To 100) As String
Dim mstrAdd(1 To 100) As String

Public Sub cboSite_click()
txtMask.Text = mstrSite(cboSite.ListIndex + 1)
txtSep.Text = mstrAdd(cboSite.ListIndex + 1)
End Sub

Public Sub cmdGo_Click()
Call txtSearch_Change
Call OpenInternet(Me, txtAddress.Text, Normal)
End Sub

Public Sub OpenInternet(Parent As Form, URL As String, WindowStyle As T_WindowStyle)
ShellExecute Parent.hwnd, "Open", URL, "", "", WindowStyle
End Sub

Private Sub Command_Click()
Unload Me
End Sub

Private Sub Form_Load()
Me.Caption = "Simple Search - Build " & App.Major & "." & Format(App.Minor, "00") & Format(App.Revision, "00")
'Stay on Top
SetWindowPos hwnd, conHwndTopmost, 100, 100, 505, 72, conSwpNoActivate Or conSwpShowWindow
'Set Sites
Call proSites1
'Set Window Position
Dim xTop, yLeft As Integer
xTop = GetINI("Window Position", "Top")
yLeft = GetINI("Window Position", "Left")
If xTop > (Screen.Height - Me.Height - 500) Then
Me.Top = Screen.Height - Me.Height - 500
Me.Top = xTop
End If
If yLeft > (Screen.Width - Me.Width) Then
Me.Left = Screen.Width - Me.Width
Me.Left = yLeft
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
SetINI "Window Position", "Top", Me.Top
SetINI "Window Position", "Left", Me.Left
End Sub

Public Sub proSites1()
Dim intFree, X As Integer
X = 1
intFree = FreeFile
Open App.Path & "Simple.nfv" For Input As #intFree
Do Until EOF(intFree)
Input #intFree, mstrName(X), mstrSite(X), mstrAdd(X)
X = X + 1
For X = 1 To UBound(mstrName)
If mstrName(X) <> "" Then
cboSite.AddItem (Format(X, "00") & " - " & mstrName(X))
End If
Next X

cboSite.ListIndex = 0
End Sub

Private Sub OsenXPButton1_Click()
Call txtSearch_Change
Call OpenInternet(Me, txtAddress.Text, Normal)
End Sub

Private Sub OsenXPButton2_Click()
End Sub

Private Sub txtSearch_Change()
Dim I, X As Integer
Dim strOut, strSite As String
I = InStr(1, txtMask.Text, "###")
strOut = Left(txtMask.Text, I - 1)
strSite = txtSearch.Text
txtPath.Text = strSite
X = 1
Do Until X = 0
X = InStr(1, txtPath.Text, " ")
If X <> 0 Then
txtPath.SelStart = X - 1
txtPath.SelLength = 1
txtPath.SelText = txtSep.Text
End If
strOut = strOut & txtPath.Text
If Len(txtMask.Text) - I - 2 < 1 Then
strOut = strOut
strOut = strOut & Right(txtMask.Text, Len(txtMask.Text) - I - 2)
End If
txtAddress.Text = strOut
End Sub

Private Sub txtSearch_GotFocus()
txtSearch.SelStart = 0
txtSearch.SelLength = Len(txtSearch.Text)
End Sub

Private Sub txtSearch_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call cmdGo_Click
End If
End Sub

There is about 15 websites in a drop down menu, id prefer to have a little checkbox so if the user chooses to search all 15 sites at once, then they could tick the box, enter the keyword, and search, and 15 windows or tabs etc would open, displaying the result.

Any help please, if I could add anything to the code to make this happen?

Thank you.

I Can't Search The Forum, If I Dont Know What To Search For
I would like to know how to do something, like if I were making an MSN bot, and wanted part of it to be able to change the background of MSN, or change the sounds how would I do that. Does this make any sense at all?

Search Through Recordset Using Binary Search

Is it possible to search through a recordset using a Binary Search?

What I'm doing currently is searching through a recordset of x,y coordinates and looking for the the one that is closest to the current mouse position, and then highlighting that coordinate. It goes too slow!

Instead of looping through each and every point to check it, I'd rather generate a query that includes the x and y coordinates as well as the distance from the mouse cursor (x - xPos) ^ 2 + (y + yPos) ^ 2 (where xPos is the current x position of the mouse, and yPos is the current y position of the mouse)

Then I would like to search through this recordset using the binary search to minimize the # of calculations.......but how would you do that using binary search? How do you move to a specific location in the recordset?????


Search And Search Results In Userform
I have userform with two textboxes at top, one labelled as 'search textbox'.I have listbox labelled as 'search results'.The other textbox labelled 'result textbox'.
If a user enters 3 letters in 'search text box',basing on a formula,results of that formula will display in listbox.After selecting the one of the value from list box the selected value has to be displayed in textbox2 'result textbox'.How this task can be acieved ?
my formula is =index(sheet1a$2:a$100,small(if(left(sheet1a$2:a$100,3)='search textbox'.value,row($1:$99))),row(a1)))
Thanks if any body help in this regard.

Search For Word, Then Continue With A Second Search
I am beating my head on the screen trying to resolve the final step in my project.

I Need to search a text.file for a specific word. "QQQQQ"

Once the word is found mark the location as startOfLine


starting at startOfLine begin a new search for a specific word "RRRRR"

Once the second word is found, mark the location as endOfLine

Using startOfLine and endOfLine, copy all the data between them to put on text5.text box

Dim nextline As String
Dim there As Integer
Open "c:myFile.txt" For Input As 1
Do While Not Eof(1)
    Input #1, nextline
    there = Instr(1, nextline, "QQQQQ")
     If there <> 0 Then
         'found string now = startOfLine
              'Start searching again beginnng with startOfLine for "RRRRR"
              'If found, then found string now = endOfLine
         Copy all data from startOfLine to endOfLine can copy to Text5.text
    Else If there = 0
        'delete last entry from queue
    End If
 Close #1

Anyone have an example of this? or perhaps used this code in an app?


Creating A Search Cmd To Search For Records In Db

I am trying to create a search button that will enable me to input data into text boxes on a form and show the results on a datagrid in a new form.
The form with the search button has 4 text boxes and i want to check the data inputted in the text boxes to see if they match any records in my db and then display the results on the new form. I am using ADO Data Control to access data from my MSACCESS db.
Can somebody PLEASE help me with this as i have been stuck on it for 2 days now and am getting really frustrated!!!

Search For A Text File In The Sytem And Search For The String In The Text File
i want to search for a text file called 'data.txt' in the system...and search for a string called 'hello world' in the file...the below code retrieves the first path of the file.. from this path i have to get the text file and search for the string

Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Private Declare Function SearchTreeForFile Lib "imagehlp" (ByVal RootPath As String, ByVal InputPathName As String, ByVal OutputPathBuffer As String) As Long

Public Function SearchAllDrives(pstrFile As String) As String
Dim i As Long
Dim strDrives() As String
Dim strMatch As String

For i = 1 To EnumerateDrives(strDrives)
strMatch = SearchDriveForFile(pstrFile, strDrives(i))
If Len(strMatch) <> 0 Then
SearchAllDrives = strMatch
Exit Function
End If
End Function

' Populate a 1-base array with drive designations
' for all drive types. Return number of drives found.
Public Function EnumerateDrives(pstrDrives() As String) As Long
Dim i As Long
Dim strBuffer As String
Dim strDrive As String

ReDim pstrDrives(1 To 1)
strBuffer = Space$(255)
strBuffer = Left$(strBuffer, GetLogicalDriveStrings(255, ByVal strBuffer))
Do While InStr(strBuffer, "")
strDrive = Left$(strBuffer, InStr(strBuffer, "") - 1)
i = i + 1
ReDim Preserve pstrDrives(1 To i)
pstrDrives(i) = strDrive
strBuffer = Mid$(strBuffer, Len(strDrive) + 3)
If pstrDrives(1) = "" Then
Erase pstrDrives
EnumerateDrives = 0
EnumerateDrives = i
End If
End Function

Public Function SearchDriveForFile(pstrFile As String, Optional ByVal pstrDrive As String = "C:") As String
Const MAX_PATH = 260
Dim strPath As String
Dim lngReturn As Long

strPath = String(MAX_PATH, 0)
pstrDrive = Left$(pstrDrive, 1) & ":"
If SearchTreeForFile(pstrDrive, pstrFile, strPath) <> 0 Then SearchDriveForFile = Left$(strPath, InStr(1, strPath, Chr$(0)) - 1)
End Function

How Can I Search
I would like to search all existing hard drives in the pc and get all the path of the file *.txt. how can i do that?

>i used the api functions for detecting all hard drives
>the only problem is that how can i search all the files with .txt extension so that i can store their path to a list..

thx n more power.. help me plsss..

Search IP
How can i search the IP address use in a network?

Search The Lan
Good Day To All

I Have a problem, the senarion is this I want to create a sort of search engine but not on the web nut on the LAN, I want to write a code that will enble me to text search all the computer with in the LAN,


I type a search text as VISUAL BASIC the code will search for any document (MSWord/Exell/PDF File Text File) that talks about VISUAL BASIC It will give the computer name/Directories and the File name of the document.

I plan to make this code to avoid redundancy and to be able to share others work if they are working on same topic.

Please help me or give some advise

tnx to all

Need Help Doing A Search

I was wondering if anyone can help me create a search.

I have a VB program in Excel that produces a list of items and the number of items to produce is dependant on the value in a particular cell, Ar.

I have a cell for how many I need to produce and one for how much is being produced.

Does anyone know how I can get it to find a value for the Ar cell so that what is produced is close to the amount I need to Produce. It doesn't have to be exact just as close as possible.

Thank you,

how can i make a string means all? for example i have a search text box and i want if its empty to show up all results?how can i do that? can be done?

Copyright 2005-08, All rights reserved