Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I get users input from edit1box and search

Status
Not open for further replies.

cybecks

Programmer
Apr 18, 2003
3
0
0
US
How do I get users input from edit1 box and search (iventory.txt) file and display the results in edit2.box?

Example:
user inputs in edit1 box Headphones

Search Results in edit2 box Headphones

What code do I need to put in OnSearch() to do this?

I know how to read all the data from the .txt file and I can display all the data in a MessageBox back to the user.

I'm stuck

Code:
void CMyiventoryDlg::OnSearch()
{
// TODO: Add your control notification handler code here

FILE*iventory; // File pointer
char buffer[365]; //setup buffer to store data
int i, ch;

// Open for read (will fail if file "data" does not exist)
if( (serials = fopen( "iventory.dat", "r" )) == NULL )

MessageBox("The file serials.txt was not opened");
else

MessageBox("The file 'iventory.dat' was opened"); //testing

// Read in first 365 characters and place them into the buffer
ch = fgetc( serials );
for(i = 0; (i < 365) && (feof( serials ) == 0); i++)
{
buffer = (char)ch;
ch = fgetc( serials );

}
// add null to end of string

buffer = '\0';

MessageBox(buffer); // displays all data in MessageBox

fclose(iventory); //Close files


 
>> How do I get users input from edit1 box and search (iventory.txt) file and display the results in edit2.box?

I think you're assuming that we already know what your program is supposed to do.

>> I know how to read all the data from the .txt file and I can display all the data in a MessageBox back to the user.

This directly contradicts what you said eariler. I thought you were reading from an edit box and writing to another.

>> Example:
>> user inputs in edit1 box Headphones
>> Search Results in edit2 box Headphones

That example is awfully ambiguous. If you wanted, I could give you code that would copy the value of one edit box to the other, but my common sense tells me that's not what you're aiming for.

So what are you aiming for? I don't want to flame you, but I hope you realize how hard it is for us to help you with your problem.

Will



FYI: Double check your usage of TGML. If you use TGML in code, some nasty things can happen, particularly when
Code:
[i]
is used as an array subscript. This is the code from your post, notice how in the third line everything turns italic.

for(i = 0; (i < 365) && (feof( serials ) == 0); i++)
{
buffer = (char)ch;
ch = fgetc( serials );

}
 
I think apatterno is right...
anyway you can use APIs like GetDlgItemText(xx..) and SetDlgItemText(xx...) to read from edit 1 and display that text in edit2...
but where exatly are you seraching the text of Edit1 ..in the file or where
 
Sorry, I just need to know how to search a text file and display the data back to the user in the edit2 box using Visual C++ 60.
 
I just need to know how to search a text file and display the data back to the user in the edit2 box using Visual C++ 60.

That's like saying &quot;I just need to know how to swing a golf club&quot;. There are any number of things associated with &quot;How&quot; to do that. The word &quot;just&quot; is not appropriate in either of those statements.

-pete

 
Thanks everyone... I figured things out already.... Don't need any more help...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top