|
-
October 28th, 2010, 01:08 PM
#1
split long text ? help please
hi all
i write this code and it work fine to split the text to equal part
put the problem is that ....
for example i need to see a msgbox with only max characters of "45" there no problem if it is less than 45 to see full last word
example text
The decision to bail out carmaker Chrysler was made by the narrowest of margins, President Obama's former "car czar" reveals.
now with this app i will see msg box with
The first msgbox = The decision to bail out carmaker Chrysler wa
The second one is = s made by the narrowest of margins, President
The third one is =Obama's former "car czar" reveals.
i need to see this ::
The first msgbox = The decision to bail out carmaker Chrysler
The second one is = was made by the narrowest of margins,
The third one is = President Obama's former "car czar" reveals.
i need to add a code to check the last character if it is "space" or not if not i need it to reduce value of aa until he found a "space" and show the split text.
Code:
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim lf As Integer
Dim aa As Integer
Dim bb As Integer
Dim newa As String
aa = 45
bb = 1
a = Len(Text1.Text) / aa
b = a + 1
c = 0
For lf = 1 To b
newa = Mid$(Text1.Text, bb, aa)
bb = bb + aa
MsgBox newa
Next lf
End Sub
regards
-
October 29th, 2010, 12:37 AM
#2
Re: split long text ? help please
there no one know a soulation ???
regards
-
October 29th, 2010, 12:56 AM
#3
Re: split long text ? help please
See if this helps:
Code:
Option Explicit
Private Sub Form_Load()
Dim a$, x%
a = "This is a test."
x = InStr(a, " ")
If x > 0 Then
Do While InStr(a, " ")
a = Replace(a, " ", " ")
Loop
End If
MsgBox a
End Sub
EDIT: Or, use a RichTextBox, and turn WORDWRAP on!
Last edited by dglienna; October 29th, 2010 at 01:10 AM.
-
October 29th, 2010, 10:09 AM
#4
Re: split long text ? help please
First check to see if text length > 45.
If >45 then is character 45 a space
If yes then split the string here and add a crlf
If not a space then use a loop to step backwards through the 45 characters until you find a space and split the string at that point.
Repeat the process with the remaining portion of the string until the last part is 45 or less.
Always use [code][/code] tags when posting code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|