The text should contain only complete words on each line and no longer than 20 characters.
The string supplied could be anything from 3 to hundreds of characters. Excessive characters can be ignored.
The code I came up with is in the 'Create' routine below, it can be run in a Graphical Application.
I wondered if someone can come up with simpler code to do the same thing.
Label1 As Label
Label2 As Label
Label3 As Label
Public Sub Form_Open()
BuildForm
Create("Raspberry Pi 3 Model B+ Consists of : Black Pi3 Case 2B/3B Black Modular Rpi Plus Case Sd Card Cover Black Modular Rpi Plus Case Usb Hdmi Cover Raspberry Pi 3 Model B + Raspberry Pi Universal Psu 5 1V-2 Transcend 16Gb Microsd High Capacity Class 10")
'Create("DOUBLE FACEPLATE With stuff")
'Create("Box")
End
Public Sub Create(sDesc As String)
Dim iSplit As Integer
Dim sWork, s1, s2, s3 As String
If Len(sDesc) < 21 Then
s1 = sDesc
sDesc = Replace(sDesc, s1, "")
Else
sWork = Mid(sDesc, 1, 21)
iSplit = RInStr(sWork, Chr(32)) - 1
s1 = Mid(sWork, 1, iSplit)
sDesc = Replace(sDesc, s1, "")
End If
If Len(sDesc) < 21 Then
s2 = sDesc
sDesc = Replace(sDesc, s2, "")
Else
sWork = Mid(sDesc, 1, 21)
iSplit = RInStr(sWork, Chr(32)) - 1
s2 = Mid(sWork, 1, iSplit)
sDesc = Replace(sDesc, s2, "")
Endif
If Len(sDesc) < 21 Then
s3 = sDesc
Else
sWork = Mid(sDesc, 1, 21)
iSplit = RInStr(sWork, Chr(32)) - 1
s3 = Mid(sWork, 1, iSplit)
Endif
Label1.Text = Trim(s1)
Label2.Text = Trim(s2)
Label3.Text = Trim(s3)
End
Public Sub BuildForm()
With Me
.Height = 88
.Width = 192
.Arrangement = Arrange.Vertical
.Padding = 5
End With
With Label1 = New Label(Me) As "Label1"
.H = 28
.W = 100
.Alignment = Align.Center
End With
With Label2 = New Label(Me) As "Label2"
.H = 28
.W = 100
.Alignment = Align.Center
End With
With Label3 = New Label(Me) As "Label3"
.H = 28
.W = 100
.Alignment = Align.Center
End With
End