Android Question How do I set profile image as first letters of first and last name like Telegram?

Mehrzad238

Member
hello everyone,
I looked into the forum for this question of mine but just couldn't find it. so I want to create that in B4A but don't know how.
any help would be appreciated.
 
Solution
B4X:
Dim UserName As String = "Aeric Poon"
Dim Names() As String = Regex.Split(" ", UserName.Trim)
Dim Initials As String

If Names.Length > 1 Then
    'Initials = Names(0).SubString2(0, 1) & Names(Names.Length - 1).SubString2(0, 1)
    Initials = Names(0).SubString2(0, 1) & Names(1).SubString2(0, 1)
Else
    If Names(0).Length > 0 Then
        Initials = Names(0).SubString2(0, 1)
    End If
End If
LblFirstLastName.Text = UserName
LblShortName.Text = Initials.ToUpperCase

aeric

Expert
Licensed User
Longtime User
B4X:
Dim UserName As String = "Aeric Poon"
Dim Names() As String = Regex.Split(" ", UserName.Trim)
Dim Initials As String

If Names.Length > 1 Then
    'Initials = Names(0).SubString2(0, 1) & Names(Names.Length - 1).SubString2(0, 1)
    Initials = Names(0).SubString2(0, 1) & Names(1).SubString2(0, 1)
Else
    If Names(0).Length > 0 Then
        Initials = Names(0).SubString2(0, 1)
    End If
End If
LblFirstLastName.Text = UserName
LblShortName.Text = Initials.ToUpperCase
 

Attachments

  • Initials.zip
    13.9 KB · Views: 83
Last edited:
Upvote 4
Solution
Top