Solved

how can i make a history in a text box

Posted on 2004-08-20
6
174 Views
Last Modified: 2010-05-02
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
0
Comment
Question by:Johnny
  • 3
  • 2
6 Comments
 
LVL 18

Expert Comment

by:JR2003
ID: 11856838
You would be better off using a combobox for this instead of a textbox.
0
 

Author Comment

by:Johnny
ID: 11856904
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
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 11857197
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
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 18

Accepted Solution

by:
JR2003 earned 500 total points
ID: 11857716
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
            Command1_Click
        ElseIf KeyCode = vbKeyEscape Then
            .Text = ""
        End If
    End With
   
End Sub

0
 

Author Comment

by:Johnny
ID: 11858425
please bare with me i wont be able to get to tghis tight away will try to check on it sunday aug,22
0
 

Author Comment

by:Johnny
ID: 11866720
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..
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ms access #TYPE! error on report when no data 4 75
Excel VBA combine two working workbooks 8 53
Spell Check in VB6 13 112
Excel Automation VBA 19 67
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now