Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TEST FOR NULL STRING

Status
Not open for further replies.

IncredibleVolk

Technical User
Apr 2, 2004
67
US
A null string is one whose first character has the value 0 (zero). nullstr is more commonly used as an expression for if/while/elseif statements.

If the above statement is true then I need a way to test if nothing is contained within a string. I need to delete columns in Excel if a specific cell is blank and the following is not working:

ddeexecute LinkVar "[SELECT(`"R7C5`")]"
dderequest LinkVar "R7C5" szTextd ;request cell value
usermsg "%s" szTextd
if nullstr SzTextd
ddeexecute LinkVar "[SELECT(`"C5`")]" ;select column 5
sendkey ALT 'E' ;Edit
pause 1
sendkey 'D' ;delete
pause 2
endif
 
In my past experience, it seemed like strings from apparently-blank cells in Excel actually contained a carriage return and line feed. Here is some text from my site with a workaround:

When retrieving a string from an Excel spreadsheet via DDE, be aware that the string will have a carriage return and linefeed at the end of it. You can use the commands strreplace szText "`n" "" and strreplace szText "`r" "" to strip these extra characters out.

Did you get the other Excel problem you posted about a day or so ago resolved? I haven't had time yet to dig into that (I so love DDE).


aspect@aspectscripting.com
 
Thank You, I should have guessed that. With regards to the other problem, the answer is no. Is there anywhere I can obtain information on how to format an Excel spreadhseet using DDE. This worked:

ddeexecute LinkVar "[FONT.PROPERTIES(`"Times New Roman`",`"Bold`",10)]"

However,

This didn't:

ddeexecute LinkVar "[FORMAT.NUMBER(`"Number`",`"Decimal Places`",2)]"

 
Another reader here sent me a Microsoft knowledge base article a while back that contains a link to a help file for Excel 97 that you might find useful (if you haven't seen it already). The link is:


I'll try to take a look at your other message later tonight and see if I can find out anything further.


aspect@aspectscripting.com
 
Did you get this one figured out? According to the Excel help file:

Syntax

FORMAT.NUMBER(format_text)
FORMAT.NUMBER?(format_text)

Format_text is a format string, such as "#, ##0.00", specifying which format to apply to the selection.

But I was unable to come up with the proper way to specify the format string via several DDE commands.


aspect@aspectscripting.com
 
I did a little more digging on this and found an example on my site from another user here that does what you want. Here is the command to send to get two decimal places in the selected cell:

ddeexecute LinkVar "[FORMAT.NUMBER(`"0.00`")]"

aspect@aspectscripting.com
 
I believe the format of the format text is the same as the format used in creating a custom number format in Excel.
(Format - Cell - Number - Custom)
Try searching Excel Help for "create custom number format" then try the link for "number" at the bottom.
This will provide detailed information on how to format number formatting strings in Excel as the "0.00" above solves forcing 2 decimal places and at least one digit before the decimal out.
 
I know this is old post, but thanks Knob...

ive been beating myself over head on why my DDE request comes back with what i need, yet still validates it incorrectly. The ol' carriage return got me...

did the strreplace and works great! WooT!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top