how can i make a history in a text box

how can i make a history ina  text box so when you use the uparrow or down arrow it remebered what youve typed before??

much like the old doskey fuction?

and it there a way to list whats in the history too???

thanks alot
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You would be better off using a combobox for this instead of a textbox.
JohnnyAuthor Commented:
ok JR2003 ill go for that

i have a send button and a text box on the form now

heres what i want to do

i want it to have a history of items(yep a combo box would do that) and if a user hits enter it will fire the send button

id also like to have it when an item is picked it does not fire unless the send button is pressed(so they can change stuff)

how do i go about doing that
Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
Here is some basic code that does what you requested:

Option Explicit

Private Sub Combo1_KeyPress(KeyAscii As Integer)
    Dim i As Integer
    Dim value As String
    If KeyAscii = 13 Then
        KeyAscii = 0
        value = Combo1.Text
        If value <> "" Then
            ' do something with value
            Debug.Print value

            ' remove item from middle of list if it exists
            For i = 1 To Combo1.ListCount - 1
                If Combo1.List(i) = value Then
                    Combo1.RemoveItem (i)
                    Exit For
                End If
            Next i
            ' add item to top of the list
            Combo1.AddItem value, 0
            ' reset the combobox
            Combo1.Text = ""
        End If
    End If
End Sub

Private Sub Command1_Click()
    Combo1_KeyPress (13) ' simulate enter being pressed on combobox
End Sub
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

To run this code:
1) start a new project
2) Add a button, Command1 which you will use for sending
3) Add a Combobox for entering text

Option Explicit

Private Sub Form_Load()
    With Command1
        .Caption = "Send..."
    End With
    With Combo1
        .Text = ""
    End With

End Sub

Private Sub Command1_Click()

    'Send text from Combo1 here
    Dim sCommand As String
    Dim sPrevCommand As String
    With Combo1
        sCommand = Trim(.Text)
        If .ListCount > 0 Then
            sPrevCommand = .List(0)
        End If
        If (sPrevCommand <> sCommand) And sCommand <> "" Then
            .AddItem .Text, 0
            .ListIndex = .NewIndex
        End If
        Debug.Print "Sending " & sCommand
    End With
End Sub

Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
    With Combo1
        If KeyCode = vbKeyReturn Then
        ElseIf KeyCode = vbKeyEscape Then
            .Text = ""
        End If
    End With
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JohnnyAuthor Commented:
please bare with me i wont be able to get to tghis tight away will try to check on it sunday aug,22
JohnnyAuthor Commented:
please give me a few days for this guys im having personel prroblems right now but i will get back to it thanks for the replys one looks as if it will work..
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.