PC Review


Reply
Thread Tools Rate Thread

Convert string

 
 
=?Utf-8?B?RXhjZWwgRVNH?=
Guest
Posts: n/a
 
      5th Jun 2007
Hello,

I have a string wich I want to convert.
All spaces should be replaced by an underscore,
and an (alt-enter) should be inserted after an underscore so that the string
is wrapped to a max length of 13 characters

e.g "Thanks very much in advance" should result in

Thanks_very_(Alt-Enter)
much_in_(Alt-Enter)
advance

Someone told me it should be possible with an UDF,
but I have no experience with that


 
Reply With Quote
 
 
 
 
=?Utf-8?B?R2FyeScncyBTdHVkZW50?=
Guest
Posts: n/a
 
      5th Jun 2007
A tiny question:

What should the function do to words like "chronosynclastic" which exceed 13
character with spaces?
--
Gary''s Student - gsnu200727


"Excel ESG" wrote:

> Hello,
>
> I have a string wich I want to convert.
> All spaces should be replaced by an underscore,
> and an (alt-enter) should be inserted after an underscore so that the string
> is wrapped to a max length of 13 characters
>
> e.g "Thanks very much in advance" should result in
>
> Thanks_very_(Alt-Enter)
> much_in_(Alt-Enter)
> advance
>
> Someone told me it should be possible with an UDF,
> but I have no experience with that
>
>

 
Reply With Quote
 
=?Utf-8?B?QmVuIE1jQmVu?=
Guest
Posts: n/a
 
      5th Jun 2007
Something like:

Public Function ChopAndTrim(strInput As String, intChopLen As Integer) As
String

Dim strArr() As String
Dim strTmp As String
Dim strOut As String
Dim i As Long

strArr = Split(strInput, " ")
For i = LBound(strArr) To UBound(strArr)
If Len(strTmp) + Len(strArr(i)) > intChopLen Then
strOut = strOut & strTmp & vbCrLf
strTmp = strArr(i) & "_"
Else
strTmp = strTmp & strArr(i) & "_"
End If
If i = UBound(strArr) Then
strOut = strOut & strArr(i)
End If
Next i

ChopAndTrim = strOut

End Function

You will need to set formatting to wrap text....



"Excel ESG" wrote:

> Hello,
>
> I have a string wich I want to convert.
> All spaces should be replaced by an underscore,
> and an (alt-enter) should be inserted after an underscore so that the string
> is wrapped to a max length of 13 characters
>
> e.g "Thanks very much in advance" should result in
>
> Thanks_very_(Alt-Enter)
> much_in_(Alt-Enter)
> advance
>
> Someone told me it should be possible with an UDF,
> but I have no experience with that
>
>

 
Reply With Quote
 
=?Utf-8?B?dmJhcHJv?=
Guest
Posts: n/a
 
      5th Jun 2007
vbCrLf gives extra unnecessary CR symbol which can be displayed as a square,
that is why nicer to use vbLf

"Ben McBen" wrote:

> Something like:
>
> Public Function ChopAndTrim(strInput As String, intChopLen As Integer) As
> String
>
> Dim strArr() As String
> Dim strTmp As String
> Dim strOut As String
> Dim i As Long
>
> strArr = Split(strInput, " ")
> For i = LBound(strArr) To UBound(strArr)
> If Len(strTmp) + Len(strArr(i)) > intChopLen Then
> strOut = strOut & strTmp & vbCrLf
> strTmp = strArr(i) & "_"
> Else
> strTmp = strTmp & strArr(i) & "_"
> End If
> If i = UBound(strArr) Then
> strOut = strOut & strArr(i)
> End If
> Next i
>
> ChopAndTrim = strOut
>
> End Function
>
> You will need to set formatting to wrap text....
>
>
>
> "Excel ESG" wrote:
>
> > Hello,
> >
> > I have a string wich I want to convert.
> > All spaces should be replaced by an underscore,
> > and an (alt-enter) should be inserted after an underscore so that the string
> > is wrapped to a max length of 13 characters
> >
> > e.g "Thanks very much in advance" should result in
> >
> > Thanks_very_(Alt-Enter)
> > much_in_(Alt-Enter)
> > advance
> >
> > Someone told me it should be possible with an UDF,
> > but I have no experience with that
> >
> >

 
Reply With Quote
 
=?Utf-8?B?QmVuIE1jQmVu?=
Guest
Posts: n/a
 
      5th Jun 2007
Dos that depend on font family?

"vbapro" wrote:

> vbCrLf gives extra unnecessary CR symbol which can be displayed as a square,
> that is why nicer to use vbLf
>
> "Ben McBen" wrote:
>
> > Something like:
> >
> > Public Function ChopAndTrim(strInput As String, intChopLen As Integer) As
> > String
> >
> > Dim strArr() As String
> > Dim strTmp As String
> > Dim strOut As String
> > Dim i As Long
> >
> > strArr = Split(strInput, " ")
> > For i = LBound(strArr) To UBound(strArr)
> > If Len(strTmp) + Len(strArr(i)) > intChopLen Then
> > strOut = strOut & strTmp & vbCrLf
> > strTmp = strArr(i) & "_"
> > Else
> > strTmp = strTmp & strArr(i) & "_"
> > End If
> > If i = UBound(strArr) Then
> > strOut = strOut & strArr(i)
> > End If
> > Next i
> >
> > ChopAndTrim = strOut
> >
> > End Function
> >
> > You will need to set formatting to wrap text....
> >
> >
> >
> > "Excel ESG" wrote:
> >
> > > Hello,
> > >
> > > I have a string wich I want to convert.
> > > All spaces should be replaced by an underscore,
> > > and an (alt-enter) should be inserted after an underscore so that the string
> > > is wrapped to a max length of 13 characters
> > >
> > > e.g "Thanks very much in advance" should result in
> > >
> > > Thanks_very_(Alt-Enter)
> > > much_in_(Alt-Enter)
> > > advance
> > >
> > > Someone told me it should be possible with an UDF,
> > > but I have no experience with that
> > >
> > >

 
Reply With Quote
 
=?Utf-8?B?dmJhcHJv?=
Guest
Posts: n/a
 
      5th Jun 2007
It does, but many high-usage fonts display this square. And the meaning of
vbLf is “soft” manual line breaking, while vbCrLf means a new paragraph.

"Ben McBen" wrote:

> Dos that depend on font family?
>
> "vbapro" wrote:
>
> > vbCrLf gives extra unnecessary CR symbol which can be displayed as a square,
> > that is why nicer to use vbLf
> >
> > "Ben McBen" wrote:
> >
> > > Something like:
> > >
> > > Public Function ChopAndTrim(strInput As String, intChopLen As Integer) As
> > > String
> > >
> > > Dim strArr() As String
> > > Dim strTmp As String
> > > Dim strOut As String
> > > Dim i As Long
> > >
> > > strArr = Split(strInput, " ")
> > > For i = LBound(strArr) To UBound(strArr)
> > > If Len(strTmp) + Len(strArr(i)) > intChopLen Then
> > > strOut = strOut & strTmp & vbCrLf
> > > strTmp = strArr(i) & "_"
> > > Else
> > > strTmp = strTmp & strArr(i) & "_"
> > > End If
> > > If i = UBound(strArr) Then
> > > strOut = strOut & strArr(i)
> > > End If
> > > Next i
> > >
> > > ChopAndTrim = strOut
> > >
> > > End Function
> > >
> > > You will need to set formatting to wrap text....
> > >
> > >
> > >
> > > "Excel ESG" wrote:
> > >
> > > > Hello,
> > > >
> > > > I have a string wich I want to convert.
> > > > All spaces should be replaced by an underscore,
> > > > and an (alt-enter) should be inserted after an underscore so that the string
> > > > is wrapped to a max length of 13 characters
> > > >
> > > > e.g "Thanks very much in advance" should result in
> > > >
> > > > Thanks_very_(Alt-Enter)
> > > > much_in_(Alt-Enter)
> > > > advance
> > > >
> > > > Someone told me it should be possible with an UDF,
> > > > but I have no experience with that
> > > >
> > > >

 
Reply With Quote
 
=?Utf-8?B?RXhjZWwgRVNH?=
Guest
Posts: n/a
 
      5th Jun 2007
Ive tried the function but the result is 2 (Alt-Enter) in front of the text

Ive copy an pasted the function so I dindnt make a typing error,

What is wrong ?

--

"Ben McBen" wrote:

> Something like:
>
> Public Function ChopAndTrim(strInput As String, intChopLen As Integer) As
> String
>
> Dim strArr() As String
> Dim strTmp As String
> Dim strOut As String
> Dim i As Long
>
> strArr = Split(strInput, " ")
> For i = LBound(strArr) To UBound(strArr)
> If Len(strTmp) + Len(strArr(i)) > intChopLen Then
> strOut = strOut & strTmp & vbCrLf
> strTmp = strArr(i) & "_"
> Else
> strTmp = strTmp & strArr(i) & "_"
> End If
> If i = UBound(strArr) Then
> strOut = strOut & strArr(i)
> End If
> Next i
>
> ChopAndTrim = strOut
>
> End Function
>
> You will need to set formatting to wrap text....
>
>
>
> "Excel ESG" wrote:
>
> > Hello,
> >
> > I have a string wich I want to convert.
> > All spaces should be replaced by an underscore,
> > and an (alt-enter) should be inserted after an underscore so that the string
> > is wrapped to a max length of 13 characters
> >
> > e.g "Thanks very much in advance" should result in
> >
> > Thanks_very_(Alt-Enter)
> > much_in_(Alt-Enter)
> > advance
> >
> > Someone told me it should be possible with an UDF,
> > but I have no experience with that
> >
> >

 
Reply With Quote
 
=?Utf-8?B?dmJhcHJv?=
Guest
Posts: n/a
 
      5th Jun 2007
try with change vbCrLf by vbLf

"Excel ESG" wrote:

> Ive tried the function but the result is 2 (Alt-Enter) in front of the text
>
> Ive copy an pasted the function so I dindnt make a typing error,
>
> What is wrong ?
>
> --
>
> "Ben McBen" wrote:
>
> > Something like:
> >
> > Public Function ChopAndTrim(strInput As String, intChopLen As Integer) As
> > String
> >
> > Dim strArr() As String
> > Dim strTmp As String
> > Dim strOut As String
> > Dim i As Long
> >
> > strArr = Split(strInput, " ")
> > For i = LBound(strArr) To UBound(strArr)
> > If Len(strTmp) + Len(strArr(i)) > intChopLen Then
> > strOut = strOut & strTmp & vbCrLf
> > strTmp = strArr(i) & "_"
> > Else
> > strTmp = strTmp & strArr(i) & "_"
> > End If
> > If i = UBound(strArr) Then
> > strOut = strOut & strArr(i)
> > End If
> > Next i
> >
> > ChopAndTrim = strOut
> >
> > End Function
> >
> > You will need to set formatting to wrap text....
> >
> >
> >
> > "Excel ESG" wrote:
> >
> > > Hello,
> > >
> > > I have a string wich I want to convert.
> > > All spaces should be replaced by an underscore,
> > > and an (alt-enter) should be inserted after an underscore so that the string
> > > is wrapped to a max length of 13 characters
> > >
> > > e.g "Thanks very much in advance" should result in
> > >
> > > Thanks_very_(Alt-Enter)
> > > much_in_(Alt-Enter)
> > > advance
> > >
> > > Someone told me it should be possible with an UDF,
> > > but I have no experience with that
> > >
> > >

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      5th Jun 2007
even better to use vbNewLine, that works on the Mac too

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"vbapro" <(E-Mail Removed)> wrote in message
newsF834ADE-34B9-4087-A022-(E-Mail Removed)...
> It does, but many high-usage fonts display this square. And the meaning of
> vbLf is "soft" manual line breaking, while vbCrLf means a new paragraph.
>
> "Ben McBen" wrote:
>
>> Dos that depend on font family?
>>
>> "vbapro" wrote:
>>
>> > vbCrLf gives extra unnecessary CR symbol which can be displayed as a
>> > square,
>> > that is why nicer to use vbLf
>> >
>> > "Ben McBen" wrote:
>> >
>> > > Something like:
>> > >
>> > > Public Function ChopAndTrim(strInput As String, intChopLen As
>> > > Integer) As
>> > > String
>> > >
>> > > Dim strArr() As String
>> > > Dim strTmp As String
>> > > Dim strOut As String
>> > > Dim i As Long
>> > >
>> > > strArr = Split(strInput, " ")
>> > > For i = LBound(strArr) To UBound(strArr)
>> > > If Len(strTmp) + Len(strArr(i)) > intChopLen Then
>> > > strOut = strOut & strTmp & vbCrLf
>> > > strTmp = strArr(i) & "_"
>> > > Else
>> > > strTmp = strTmp & strArr(i) & "_"
>> > > End If
>> > > If i = UBound(strArr) Then
>> > > strOut = strOut & strArr(i)
>> > > End If
>> > > Next i
>> > >
>> > > ChopAndTrim = strOut
>> > >
>> > > End Function
>> > >
>> > > You will need to set formatting to wrap text....
>> > >
>> > >
>> > >
>> > > "Excel ESG" wrote:
>> > >
>> > > > Hello,
>> > > >
>> > > > I have a string wich I want to convert.
>> > > > All spaces should be replaced by an underscore,
>> > > > and an (alt-enter) should be inserted after an underscore so that
>> > > > the string
>> > > > is wrapped to a max length of 13 characters
>> > > >
>> > > > e.g "Thanks very much in advance" should result in
>> > > >
>> > > > Thanks_very_(Alt-Enter)
>> > > > much_in_(Alt-Enter)
>> > > > advance
>> > > >
>> > > > Someone told me it should be possible with an UDF,
>> > > > but I have no experience with that
>> > > >
>> > > >



 
Reply With Quote
 
=?Utf-8?B?QmVuIE1jQmVu?=
Guest
Posts: n/a
 
      5th Jun 2007
Not sure! Perhaps you found a bug in my code. What string are you trying to
parse? Did you set wrap text? I dont think the VbCrLf change will make much
difference (I think you would just see a graphics character at the end of
each line with certain fonts)

You are using this in a cell arent you?

"Excel ESG" wrote:

> Ive tried the function but the result is 2 (Alt-Enter) in front of the text
>
> Ive copy an pasted the function so I dindnt make a typing error,
>
> What is wrong ?
>
> --
>
> "Ben McBen" wrote:
>
> > Something like:
> >
> > Public Function ChopAndTrim(strInput As String, intChopLen As Integer) As
> > String
> >
> > Dim strArr() As String
> > Dim strTmp As String
> > Dim strOut As String
> > Dim i As Long
> >
> > strArr = Split(strInput, " ")
> > For i = LBound(strArr) To UBound(strArr)
> > If Len(strTmp) + Len(strArr(i)) > intChopLen Then
> > strOut = strOut & strTmp & vbCrLf
> > strTmp = strArr(i) & "_"
> > Else
> > strTmp = strTmp & strArr(i) & "_"
> > End If
> > If i = UBound(strArr) Then
> > strOut = strOut & strArr(i)
> > End If
> > Next i
> >
> > ChopAndTrim = strOut
> >
> > End Function
> >
> > You will need to set formatting to wrap text....
> >
> >
> >
> > "Excel ESG" wrote:
> >
> > > Hello,
> > >
> > > I have a string wich I want to convert.
> > > All spaces should be replaced by an underscore,
> > > and an (alt-enter) should be inserted after an underscore so that the string
> > > is wrapped to a max length of 13 characters
> > >
> > > e.g "Thanks very much in advance" should result in
> > >
> > > Thanks_very_(Alt-Enter)
> > > much_in_(Alt-Enter)
> > > advance
> > >
> > > Someone told me it should be possible with an UDF,
> > > but I have no experience with that
> > >
> > >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert 'System.Collections.ObjectModel.ReadOnlyCollection(Of String)' to '1-dimensional array of String'. roidy Microsoft VB .NET 12 17th Jul 2009 10:53 AM
Convert Dictionary<string,SomeType> keys to List<string> buzzweetman@gmail.com Microsoft C# .NET 6 9th Aug 2006 03:54 PM
convert html-string to plain text-string Nedo Microsoft Dot NET 4 28th Jul 2005 09:53 AM
Connection String object Convert to String Variable Type =?Utf-8?B?TWlrZSBNb29yZQ==?= Microsoft ASP .NET 2 26th Oct 2004 03:43 PM
Convert a string to Ascii codes and then back to string again Kai Bohli Microsoft C# .NET 11 8th Jul 2004 03:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:17 AM.