rwblinn Well-Known Member Licensed User Longtime User Jun 18, 2013 #1 Dear All, how to insert Date/Time at cursor position multiline EditText? Appreciated, Robert
Erel B4X founder Staff member Licensed User Longtime User Jun 18, 2013 #2 You can use this method to insert strings inside a string: Code: Copy Sub Insert(original As String, ins As String, index As Int) As String Dim pre, suf As String If index > 0 Then pre = original.SubString2(0, index) If index < original.Length Then suf = original.SubString(index) Return pre & ins & suf End Sub Your code: Code: Copy Dim str As String = DateUtils.TicksToString(DateTime.Now) et.Text = Insert(et.Text,str , et.SelectionStart) et.SelectionStart = et.SelectionStart + str.Length Upvote 0
You can use this method to insert strings inside a string: Code: Copy Sub Insert(original As String, ins As String, index As Int) As String Dim pre, suf As String If index > 0 Then pre = original.SubString2(0, index) If index < original.Length Then suf = original.SubString(index) Return pre & ins & suf End Sub Your code: Code: Copy Dim str As String = DateUtils.TicksToString(DateTime.Now) et.Text = Insert(et.Text,str , et.SelectionStart) et.SelectionStart = et.SelectionStart + str.Length
rwblinn Well-Known Member Licensed User Longtime User Jun 18, 2013 #3 Insert DateTime @cursor position in EditText Erel, works perfect. Many thanks for this solution. Rob Upvote 0