go to first/last entry button

M162

New member
Joined
Sep 5, 2007
Messages
3
Programming Experience
Beginner
Im a beginner in programming...

I've been trying to make an agenda that has textbox with data...
example: ID, Name, Last Name, Age, Job

what I want to do is that when you click the button ">>" it goes to the last entry, when I the button "<<" it goes to the first one, when you click the button ">" it goes to the next one.

I saw my teacher doing something with an array x(10), and methods x.getupperbound, x.getlowerbound or something like that... I can't really remember...

Help is much appreciated, thank you :)
 
You've given very little information. You haven't said where this data is stored for a start. How can we tell you how to go to the last entry if we don't know what we're going to the last entry of? I'm going to assume from what you have said that you have an array of Strings and you are assigning each one to the Text property of your TextBox as required. In that case you certainly could use the GetUpperBound and GetLowerBound methods:
VB.NET:
'Display the last entry.
myTextBox.Text = myArray(myArray.GetUpperBound(0))
That gets the index of the last element, then gets the element at that index. Similarly this will get the index of the first element:
VB.NET:
'Display the first entry.
myTextBox.Text = myArray(myArray.GetLowerBound(0))
That said, given that .NET arrays are always zero-based except in VERY specific circumstances it would be safe to just do this:
VB.NET:
'Display the first entry.
myTextBox.Text = myArray(0)
 
thank you for your answer im sorry i didnt make myself clear... I have a bunch of textbox with method ".text" each have an assigned variable... example:
txtname.text=name
txtid.text=id
....

the "<<" "<" ">" ">>"... are for position in index, example when I click on button ">" it will display all information in the next x array index, on the textbox control.

When I click on ">>" it will display all information on last page.

Data is stored in buttons I believe... if that makes sense... If the position is x(1) then it will say "john" on txtname.text, on txtid it will say "1"...
if position is x(2) it will say "james" on txtname.text.... and so on...

Im probably talking nonsense since im just a beginner...

this is how its supposed to look:
 
Data cannot be stored in buttons (not the data we are referring to anyway). Data is stored in some sort of datastore, usually a database but it can also be in a flat file such as a text or xml based file. By stored here I mean that the information is persisted after closing the application. It is also possible to store the data temporarily in memory in the form of arrays or even better, collections; there are many possibilities.
 
Like Paszt says, you would normally have your data stored in some persistent form, like a file or a database. The most common is a real-world situation would be a database. You would normally execute an SQL query to populate a DataTable, which you would then bind to your TextBoxes via a BindingSource. To navigate the data you'd then call the MoveFirst, MovePrevious, MoveNext and MoveLast methods of the BindingSource.

If yours is a learning project then you may not be up to using database. The problem is, you really haven't given us a proper explanation of how your app works. As Paszt says, data cannot be stored in buttons. Do you actually mean that when you press a button the data is retrieved from somewhere? Where does the data come from? Assume we know nothing about your app and EXPLAIN it to us.
 
Back
Top