Retrieving data from text box and sort descending in a list

  • Thread starter Thread starter Carl_and_Earl
  • Start date Start date
C

Carl_and_Earl

I have a form and many text boxes. I want to retreive the date from the text
box and sort it in the list box on the right descending.
Seems simple, but I don't know how to do that.

Thanks.
 
You can create an array, load the data from your text boxes into the array,
then sort the array. There are a number of algorithms for sorting an
array - just search for VB sort array. Here's one sample, along with the
web site I took it from. This code will pop up some input boxes. The first
asks how many elements are in your array, then you'll see an input box for
each element. The function will sort them in descending order.


http://www.a1vbcode.com/snippet-4110.asp

Private Sub SortArrayDescending()

Dim A(20) As Integer
Dim num, i, j, k, arr, temp As Integer
Dim strOutput As String

num = InputBox("Intialize the size of your array:")
For i = 0 To num - 1
A(i) = InputBox("Enter your array: ")
Next i

'this will sort your array in descending order
For i = 0 To num - 1
For j = i + 1 To num - 1
If A(i) < A(j) Then
temp = A(i)
A(i) = A(j)
A(j) = temp
End If
Next j
Next i

For i = 0 To num - 1
strOutput = strOutput & A(i) & ";"
Next i

MsgBox strOutput

End Sub
 
I have a form and many text boxes. I want to retreive the date from the text
box and sort it in the list box on the right descending.
Seems simple, but I don't know how to do that.

Thanks.

STOP.

Forms *do not contain data*.
You cannot "sort a form".

Data is stored in Tables, and only in tables; a Form is just a tool, a window
to let you work with data in tables.

How does the data (date??) get into the textbox? Is it typed in, copied and
pasted from somewhere, or <gasp> displayed from a Table to which the form is
bound?

More info please!
 
The text boxes are bound to a table. The form helps me to input (typed in) in
a nice view the date on that table.

I want somehow to sort in a list box or something else the column that
contains the dates from that text box.

Thanks.
 
The text boxes are bound to a table. The form helps me to input (typed in) in
a nice view the date on that table.

I want somehow to sort in a list box or something else the column that
contains the dates from that text box.

Again:

You *cannot sort a textbox*.

You can base a Listbox or Subform on a Query retrieving data from a table;
that Query can, if you wish, use a textbox or other control as a criterion to
limit the data.

You have not explained your table structure or how the form is set up. "nice
view the date on that table" is not meaningful to me... could you perhaps post
a bit more description??
 
Back
Top