Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MSCOMM.INPUT - STRING MANIPULATION

Posted on 1999-07-23
2
Medium Priority
?
182 Views
Last Modified: 2013-12-25
I HAVE WHAT SOME MIGHT CALL A BIT OF A PROBLEM WITH A EMULATOR::::
i have a string com in on a com port
just like this

public buffer2 as variant
___________________________________________________________
private static sub mscomm1_oncomm()

     select case mscomm1.commevent
           case comevreceive
           dim buffer as variant
           buffer = mscomm1.input
           buffer2 = buffer
easy enough, well ok the string i have comming in has and escape character (chr(27)) followed by a 4 diget number, in which the first two digets handle my row and the second two digets handle my colum.  This is then followed by clear text to be displayed on the screen, which i will never know the string length, which will be followed by another escape character (chr(27)) and 4 digits (row,col) and clear text
every time i get a escape character i need to set my row and col (which i have my control array already made and my functions that set this)
--- i believe their has to be some way to load buffer into buffer2 and then as i get what i need out of buffer2 delete it and as buffer fills up what ever information is fill into buffer will be added to buffer2.
ex: of string

(chr(27))0107mscomm controls are hard to get help with.(chr(27))0308but only in visual basic.


as you can see i need help!!!!!!!!!!!!!
rock
0
Comment
Question by:rockie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
Dalin earned 800 total points
ID: 1495577
First, you can use text instead of an variant unless you are doing binary transfer.

You can do something like this:
Private Sub sHandleComData()
    Dim lRow As Integer
    Dim lCol As Integer
    Dim lPos As Integer
    Dim lString As String

    Do While Len(mStComData) > 0
            If Left(mStComData, 1) = Chr(27) Then
                    lRow = CInt(Mid(mStComData, 2, 2))
                    lCol = CInt(Mid(mStComData, 4, 2))
                    'Find the next Chr(27)
                    lPos = InStr(1, mStComData, Chr(27))
                    If lPos > 0 Then
                            ' got it
                            lString = Left(mStComData, lPos)
                            mStComData = Right(mStComData, Len(nstComData) - lPos + 1)
                           
                        Else
                            lString = mStComData
                            mStComData = ""
                        End If
                Else
                    lPos = InStr(1, mStComData, Chr(27))
                    If lPos > 0 Then
                             mStComData = Right(mStComData, Len(nstComData) - lPos + 1)
                        End If
                End If
               
            DoEvent
           
            ' Now use the lCol and Lrow to do your thing.
 
         
         Loop
    End Sub

in your OnComEvent, do

    select case mscomm1.commevent
                        case comevreceive
                       
                        mStComdata  = mStComData & mscomm1.input
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6821951
This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.

This is the Community Support link, if help is needed, along with the link to All Topics since many new ones were recently added.

http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
http://www.experts-exchange.com/jsp/zonesAll.jsp
 
Thanks,
Moondancer
Moderator @ Experts Exchange
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

715 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