0
votes

I am writing Lotusscript agent, how do I say that I need to take value in the right of space character? For example this takes value in the right of /:

fld9.Value = StrRight(Cstr(doc.request(0)), "/") 

but if I put space instead of /, it does not work. Do I need to write some kind of code there?

Thanks

2

2 Answers

2
votes

Are you sure, that the character you want to find is a space and not another whitespace character?

If it IS a space, then this would work same as in your example:

fld9.Value = StrRight(Cstr(doc.request(0)), " ")

Or to be more flexible

Dim strSpace as String
strSpace = Chr$(20)
fld9.Value = StrRight(Cstr(doc.request(0)), strSpace)

To find out, what you got there, you take a string (that you probably know) and do this:

Dim strSpaceChar As String
Dim lngAsc as Long
strSpaceChar = Mid$("Your String with a space", 5, 1)
' 5 = Position of the "space" character, 1 = Number characters
lngAsc = Asc( strSpaceChar )

If lngAsc <> 20 then you need to replace strSpace in the example above with the right Character...

If there might be different "spaces" in the text and you do not know before the run, then make an array with all known variations of "space" (the example below would consider NewLines and an HTML nbsp as Spaces)

Dim arrSpaces( 3 ) as String
arrSpaces( 0 ) = Chr$( 10 )
arrSpaces( 1 ) = Chr$( 13 )
arrSpaces( 2 ) = Chr$( 0 )
arrSpaces( 3 ) = Chr$( 160 )

and replace it with a "real" space...

myString = Replace( Cstr(doc.request(0)) , arrSpaces , Chr$(20) )

EDIT because of new kind of question: There are classes to handle Date / Time values. You could do something like:

Dim dtRequest as NotesDateTime
Dim strDate as String
Dim strTime as String
Set dtRequest = New NotesDateTime( doc.request(0) )
strDate = dtRequest.DateOnly
strTime = dtRequest.TimeOnly
1
votes

It does work with space " " for sure. My guess is that your expression Cstr(doc.request(0)) does not contain a space because Cstr() converts e.g. numbers to string without a space.

If you want to get the time from a date/time value as String then better use format():

fld9.Value = Format(doc.request(0), "hh:nn:ss")