Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Final space removed when moving to Object variable

Is there a solution to this problem? The final space in a String is
deleted when assigned to a field in an Object variable.


Dim obHead As Object
Dim strLet As String

strLet = "ABCD " 'ABCD and a final space

obHead.Value("OBJ") = strLet "obHead.Value("OBJ") contains ABCD
(no space)


Thanks for any assistance!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Final space removed when moving to Object variable

Use the trim function

either
strLet = trim("ABCD ") 'ABCD and a final space

or
obHead.Value("OBJ") = trim(strLet) "obHead.Value("OBJ") contains ABCD

"groupie" wrote:

Is there a solution to this problem? The final space in a String is
deleted when assigned to a field in an Object variable.


Dim obHead As Object
Dim strLet As String

strLet = "ABCD " 'ABCD and a final space

obHead.Value("OBJ") = strLet "obHead.Value("OBJ") contains ABCD
(no space)


Thanks for any assistance!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Final space removed when moving to Object variable

What object are you using?
What version of excel?

You may get more people to test if you share that info.

groupie wrote:

Is there a solution to this problem? The final space in a String is
deleted when assigned to a field in an Object variable.

Dim obHead As Object
Dim strLet As String

strLet = "ABCD " 'ABCD and a final space

obHead.Value("OBJ") = strLet "obHead.Value("OBJ") contains ABCD
(no space)

Thanks for any assistance!


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Final space removed when moving to Object variable

Yes,sorry should have been clearer.

I want to keep the final space from strLet in the object, notremoveit,
however the assignment to the object removes it.

Excel 2002 SP3

Seemsto happen to anything that is defined as an object.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Final space removed when moving to Object variable

Can you share one of the objects you used to see the problem?

Might as well test on one that doesn't work for you.

groupie wrote:

Yes,sorry should have been clearer.

I want to keep the final space from strLet in the object, notremoveit,
however the assignment to the object removes it.

Excel 2002 SP3

Seemsto happen to anything that is defined as an object.


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Final space removed when moving to Object variable

Ps.

I tried it with a commandbutton from the Control toolbox toolbar and this
returned 5:

Option Explicit
Sub testme()
Dim myObj As Object
Set myObj = ActiveSheet.CommandButton1
myObj.Caption = "qwer "
MsgBox Len(myObj.Caption)
End Sub



groupie wrote:

Yes,sorry should have been clearer.

I want to keep the final space from strLet in the object, notremoveit,
however the assignment to the object removes it.

Excel 2002 SP3

Seemsto happen to anything that is defined as an object.


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Final space removed when moving to Object variable

ps (again):

I used a combobox from the control toolbox toolbar and this returned 5, too.

Option Explicit
Sub testme()
Dim myObj As Object
Set myObj = ActiveSheet.ComboBox1
myObj.Value = "qwer "
MsgBox Len(myObj.Value)
End Sub

(This used .value)

groupie wrote:

Yes,sorry should have been clearer.

I want to keep the final space from strLet in the object, notremoveit,
however the assignment to the object removes it.

Excel 2002 SP3

Seemsto happen to anything that is defined as an object.


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I stop my tab from moving more than one space debrale Excel Discussion (Misc queries) 4 January 26th 07 01:16 PM
Object Variable Not Set Error on Selection object Jean Excel Worksheet Functions 3 July 24th 06 06:45 PM
Run-time Error'91: Object variable or With block variable not set DynamiteSkippy Excel Programming 4 September 26th 05 07:47 AM
Run-time error '91': "Object variable or With block variable not set Mike[_92_] Excel Programming 2 December 30th 04 10:59 AM
Cells.Find error Object variable or With block variable not set Peter[_21_] Excel Programming 2 May 8th 04 02:15 PM


All times are GMT +1. The time now is 06:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"