Jump to content

Find a user defined number


 Share

Recommended Posts

Hello,

Is it possible to make a program where users can search a database for a number and if that number is found then it displays a msgbox with the status of that number?

a sample:

A users runs check.exe

A Inputbox is shown

User puts in his number

Program searches for that number in the database

If the number exists it reads the next line with the status of that number and it then returns the status to the user by displaying a msgbox with the status.

Thanks for your help!

Link to comment
Share on other sites

Is the database in a text file, or INI file, because if so, you could just use on of the String functions to search through it.

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Link to comment
Share on other sites

I think StringInStr() might work

$result = StringInStr("I am a String", "RING")
MsgBox(0, "Search result:", $result)

$location = StringInStr("How much wood could a woodchuck chuck is a woodchuck could chuck wood?", "wood", 0, 3) ; Find the 3rd occurance of "wood"
Edited by BALA
[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Link to comment
Share on other sites

This is 1 problem registred in the database.

Name:Test

Problem: Computer doesn't start

Code: 56891

---------------------------

With the code I want users to be able to check the status of there problem. So users open a program input there problem code and then it returns the status of the problem with the code specified.

Edited by PcExpert
Link to comment
Share on other sites

So the database looks like this

CODE
Name:Test

Problem: Computer doesn't start

Code: 56891

Name:Test

Problem: Computer doesn't start

Code: 56891

Name:Test

Problem: Computer doesn't start

Code: 56891

Name:Test

Problem: Computer doesn't start

Code: 56891

Name:Test

Problem: Computer doesn't start

Code: 56891

Name:Test

Problem: Computer doesn't start

Code: 56891

Link to comment
Share on other sites

Thats right with a line like this:

---------------------------------

after each problem

So it looks like this:

Name:Test

Problem: Computer doesn't start

Code: 56891

---------------------------------

Name:Test

Problem: Computer doesn't start

Code: 56891

---------------------------------

Name:Test

Problem: Computer doesn't start

Code: 56891

---------------------------------

Name:Test

Problem: Computer doesn't start

Code: 56891

---------------------------------

Edited by PcExpert
Link to comment
Share on other sites

Next time, give more information on what you want. You mentioned 'a' database, it could have been anything! Never make others have to find out how to help you.

#include <Array.au3>

$Read = FileRead("Database.txt")
While StringInStr($Read,"--")
    $Read = StringReplace($Read,"--","-")
WEnd

$Database = StringSplit($Read,"-")
_ArrayDisplay($Database,$Database[0])

$i = InputBox("","Code?")
For $x = 1 to $Database[0]
    If StringInStr($Database[$x],$i) Then
        MsgBox(0,"Database", $Database[$x])
    EndIf
Next
Edited by Manadar
Link to comment
Share on other sites

Thanks!

If I start it I first get a msgbox displaying:

[0]= 5

[1] = Name:Test

Problem: Computer doesn't start

Code: 56891

[2] =

Name:Test

Problem: Computer doesn't start

Code: 36271

[3] =

Name:Test

Problem: Computer doesn't start

Code: 54927

[4] =

Name:Test

Problem: Computer doesn't start

Code: 22519

[5] =

Can I get rid of that? So it only displays the second msgbox with the info?
Link to comment
Share on other sites

I forgot to remove it, I used it for testing purposes.

$Read = FileRead("Database.txt")
While StringInStr($Read,"--")
    $Read = StringReplace($Read,"--","-")
WEnd

$Database = StringSplit($Read,"-")

$i = InputBox("","Code?")
For $x = 1 to $Database[0]
    If StringInStr($Database[$x],$i) Then
        MsgBox(0,"Database", $Database[$x])
    EndIf
Next
Link to comment
Share on other sites

I wait one question: How to display a msgbox if the number is not found? This is what I tried:

#include <Array.au3>

$Read = FileRead("Database.txt")

While StringInStr($Read,"--")

$Read = StringReplace($Read,"--","-")

WEnd

$Database = StringSplit($Read,"-")

$i = InputBox("","Probleemcode invoeren A.U.B.")

For $x = 1 to $Database[0]If StringInStr($Database[$x],$i) Then

MsgBox(0,"Database", $Database[$x])

Else

Msgbox(64, "Database", "Number not found.")

EndIf

Next

then it displays the msgbox 3 times or so if the number is not found I want it to just show once.
Link to comment
Share on other sites

$Read = FileRead("Database.txt")
While StringInStr($Read,"--")
$Read = StringReplace($Read,"--","-")
WEnd

$Database = StringSplit($Read,"-")

$i = InputBox("","Probleemcode invoeren A.U.B.")
For $x = 1 to $Database[0]
If StringInStr($Database[$x],$i) Then
 MsgBox(0,"Database", $Database[$x])
 Exit
EndIf
Next
Msgbox(64, "Database", "Number not found.")

Now if the number is found it quits before the "Number not found" msgbox is shown. You can delete the INclude.

Edited by Manadar
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...