Combining Number In A String

I am using a DTMF receiver connected to my parallel port to receive the tones generated by the phone. So far, when i press 1 on the phone, a 1 appears in the text box (txtNumIn). The same for 2-0.

What i would like to do is as i press the numbers 555-1212, i would like all the numbers to appear in the text box. What is happening now is 5 appears, then 5 then 5 the 2, 2, 2 and 2. I do not want the single numbers, i want all 7 to be grouped together and when the total numbers in the string reach 7 digits, for the string to stop accepting numbers and output the number to a .dat file.

So basically,

Group the dialed numbers in a string (show the digits being dialed in a text box) and when the total digits reah 7, export the data to a .dat file. I need the 7 numbers to be shown in the same text box together (555-1212) and not just 5, just 2, just 2 .......

Who is Participating?
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.

Not the best way, but wherever you are printing those numbers to the text box, use a variable instead. If the len is seven then print it out to a file or the textbox. Maybe something like this?:

'Put in Declarations
public spNum as string

'Put where you get Parrallel Port info
dim sInputChar as string

'sInputChar is input from parrallel port

'make sure we got something from p port
if len(trim(sInputChar)) > 0 then
    spNum = spNum & sInputChar 'input from p port

    if len(spNum) = 7 then
        'write to textbox
        txtout.text = spNum
        'Clear var and startover
        spNum = ""

    end if
end if

my guess is when you receive the DTMF code, you are doing something like: textbox1.text = dtmfcode each time.

change it to:
textbox1.text = textbox1.text & dtmfcode

this will append the numbers as you get them.

textbox1.text = textbox1.text & dtmfcode

Private Sub Text1_Change()
    If Len(Text1.Text) = 3 Then
        Text1.Text = Text1.Text & "-"
        Text1.SelStart = Len(Text1.Text)
    End If
    If Len(Text1.Text) = 8 Then
        AppendToFile (Text1.Text)
        Text1.Text = ""
    End If
End Sub

Sub AppendToFile(strText)
    FileNumber = FreeFile
    Open "C:\Filename.dat" For Append As FileNumber
    Print #FileNumber, strText
    Close FileNumber
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
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.