Search code examples
vbavb6libreoffice

Delete first letter of the words using visual basic


I have a code, which can change last letters of words to the dot. I need to how, how to change the code, so when I write some words, in output I will get them without first letter?

for ex:

  • Input: Hello,how are you?
  • Output: ello, ow re ou?

Here is my code:

Sub New5
dim s, ns as String
dim r as String
s = inputbox("Input text")
r = "Inputed text:" & chr(9) & s & chr(13)
for i = 2 to len(s)
if mid(s,i,1)=" " then ns = ns + "." else ns = ns + mid(s,i-1,1)
next i
ns = ns + "."
r = r & "Result of work:" & chr(9) & ns
MsgBox r
End Sub

Solution

  • For VB6:

    Private Sub Convert()
      Dim strIn as string
      Dim strA() As String
      Dim strOut As String
      Dim iX As Integer
      
      strIn - "Hello, how are you?"
      strA = Split(strIn, " ")
      
      For iX = 0 To UBound(strA)
        strA(iX) = Mid$(strA(iX), 2)
      Next
      
      strOut = Join(strA, " ")
    End Sub
    

    Incidentally your libreoffice tag is also inappropriate as LibreOffice doesn't use the same language as vb6 or vba.