Thema
Zeichenfolgen aus 1. mit Leerzeichen in 2. TextBox übernehmen
Gruppe
TextBox
Problem
Der in die erste TextBox einzugebende Text soll automatisch in die zweite mit einem Leerzeichen nach jedem vierten Zeichen übernommen werden.
ClassModule: frmSpace
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub txtSource_Change()
txtTarget.Text = SetSpaces(txtSource.Text)
End Sub
StandardModule: Modul1
Function SetSpaces(sTxt As String) As String
Dim iChar As Integer, iSpace As Integer
Dim sText As String
For iChar = 1 To Len(sTxt)
sText = sText & Mid(sTxt, iChar, 1)
iSpace = iSpace + 1
If iSpace = 4 Then
sText = sText & " "
iSpace = 0
End If
Next iChar
SetSpaces = sText
End Function
Sub CallForm()
frmSpace.Show
End Sub