Link to home
Start Free TrialLog in
Avatar of vbaddictor
vbaddictor

asked on

Text manipulation help ...

A user started a session and at the halfway , he want to remove the timestamp , it'll be

Output :
[3:00:00PM ] blahblah
[3:00:01PM ] dsadsa
dsdsa
dasdsadsa

How can i do that
Output :

blahblah
dsadsa
dsdsa
dasdsadsa

??

My original code is  :

Private Sub StatusLog(What As String)
If TimeStampValue = 1 Then   '<<< Timestamp enabled
    With txtStatus
        .SelLength = 0
        .SelStart = Len(txtStatus.Text)
        .SelColor = StatusTimeColor
        .SelText = "[ " & Time() & " ]  "
        .SelColor = StatusMainTextColor
        .SelText = What & vbCrLf
    End With
Else       'Timestamp disabled

With txtStatus
        .SelLength = 0
        .SelStart = Len(txtStatus.Text)
        .SelColor = StatusMainTextColor
        .SelText = What & vbCrLf
    End With

End If

End Sub

But it doesnt override the previous text.


-----------------

Avatar of _agj_
_agj_

what exactly do u want. Clearer plz.

"But it doesnt override the previous text."  ---> meaning?

the code looks ok, btw.
Avatar of Richie_Simonetti
It appears that you are using Richtextbox control, right?, then you need to use the specific funtions to work with RTF formated text, it appears that you are using simple text methods.
To be more specific:
.selRTF
.textRTF
i think.
With a richtextbox, the .SelText function CHANGES whatever is currently selected to the value you pass it.  If nothing is currently selected, then the .SelText function inserts its text into the richtextbox where the insert point currently is.  

To remove the time stamps, you will need to walk the contents of your box, using .SelStart and .SelLength to pick out the time stamp portions and take them out using .SelText ="".

Now it appears that the your users will be able to turn time stamps on/off at will.
A major design decision will have to be made:  

---> If time stamps are initially on, then turned off, and then later turned back on....should the original time stamps be restored?

To accomplish this, you will have to "store" the time stamps for later retrieval.

One way to do this would be by keeping your time stamps w/ messages in a collection and then rebuild the entire chat history with the appropriate colors.
You could also cheat and use two richtextboxes, one with timestamps and one without.  You can then simulate turning time stamps on/off by making one box visible while the other is not and then switching their visibility states.

I believe you also have some code that allows the user to change the stampcolor and msgcolor at will no?  If you do, then that function needs to be modified to take into account the fact that the time stamp may or may not be present in the richtextbox.

Anyway, I do ramble on....let us know how you want the chat app to behave and we can help you accomplish that.

Cheers
Avatar of vbaddictor

ASKER

Idle_Mind , ya , that's the problem ... the main problem is i dunno how to restore .. when user turn it on then off then on again .. sigh .. can u pelase help me ?
oh ic ... Idle_Mind .. using 2 rtbs might be a good solution ..
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial