AppendText to eddittext

b4AMarkO

Member
Licensed User
Longtime User
First if I need to use something besides EditText I will

I use to use a RichText Box in VB with the following code to add a time stamp ...

It would allow user to timestamp then write any notes to the stamp. Then when he was ready could another timestamp and so on.

Can I do this in Edittext ...

B4X:
   Dim myRTB As String
        Dim myTime As String
        myTime = Format(Now, "Short Time")
        myRTB = Format(Now, "Short Date")
        If rtbDes.Text <> "" Then
            rtbDes.Text = rtbDes.Text & vbCr & myRTB & ": " & myTime & ":  "
        Else
            rtbDes.Text = myRTB & ": " & myTime & ":  "
        End If
 
Last edited:

b4AMarkO

Member
Licensed User
Longtime User
I tried this but
1. Im not getting the time its a string of numbers

2. After the time stamp I need cursor start to be after the stamp so user can start typing ie; 5:34: | <--- Insert Cursor

After they type in and when ready user hits stamp again another time is inserted at next clear line ie;
5:34: Some text mmmmmmmmmmmmmm
mmmmmmm
5:47: | <------ Insertion point

here is the code I tried to modify it

B4X:
Dim now As Long
now = DateTime.now 
Dim myEt As String
Dim myTime As String
       myTime = now
        
       
If etPatrol.Text <> "" Then
      etPatrol.Text = etPatrol.Text & CRLF & myTime & ":  "
Else
      etPatrol.Text = myTime & ":  "
End If
 
Last edited:
Upvote 0

b4AMarkO

Member
Licensed User
Longtime User
Making a correction I have now figured out how to get Millitary time

However, still haven't figured how to get the Insert Curor to be at the end as described in first post
B4X:
If etPatrol.Text <> "" Then
            etPatrol.Text = etPatrol.Text & CRLF & DateTime.Time(myTime) & ":  "
Else
            etPatrol.Text = DateTime.Time(myTime) & ":  "
End If
 
Upvote 0

b4AMarkO

Member
Licensed User
Longtime User
Hope I don't just talk to myself LOL

Anyway ... I now am appending the text ... its working ok ....

However, the military time has seconds added to it how do I remove the seconds.... I don't want that.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
You are not talking to yourself. We are listening. To hide the seconds, add this to the start of your code:
B4X:
DateTime.Timeformat="HH:mm"
 
Upvote 0
Top