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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String compare problem 1

Status
Not open for further replies.

kodr

Programmer
Dec 4, 2003
368
Arg, I don't get it. Below is some code (I'm working on a DDE example I got from Knob's web site) and for some reason the string comparision is failing.

Code:
   sdlgmsgbox "Here" szText stop ok iTemp
   	;szText = "end"
            if stricmp szText "end"	        ;If cell contains the string exit
               exitwhile                        ;Exit the while loop.
            else

I'm using the dialog box to verify that the string szText is picking up "end" correctly, but the if stricmp passes it by. I forced it to "end" (the commented out line) and it works correctly.. Anyone have any ideas? I've verified that there is no leading/training whitespace.
 
Sorry, the above was not a very good 'snipet' here's more code...

Code:
   if ddeinit SystemVar "excel" "system"
      ;ddeexecute SystemVar "[FULL(TRUE)]"       ;Maximize the spreadsheet.
      if ddeinit LinkVar "excel" "sheet1"       ;Set up link to spreadsheet.
         while 1                                ;Loop forever.
            strfmt sRowCol "R%dC%d" iRow iCol1  ;Format request for data from current row, column 1
               sdlgmsgbox "Here" sRowCol stop ok iTemp
            dderequest LinkVar sRowCol szText   ;Read data from spreadsheet, current row, column 1
   sdlgmsgbox "Here" szText stop ok iTemp
   	;szText = "end"
            if stricmp szText "end"	        ;If cell contains the string exit
               exitwhile                        ;Exit the while loop.
            else
               ;strfmt sRowCol "R%dC%d" iRow iCol2
               ;dderequest LinkVar sRowCol szText;Read data from spreadsheet, current row, column 2
               iNumT ++
               sPort[iNumT] = szText
            endif
            iRow++                              ;Increment row value
         endwhile
         ddeterminate LinkVar                   ;Break DDE link to spreadsheet.
         ddeterminate SystemVar                 ;Break DDE link to Excel.
      else
         errormsg "Couldn't establish DDE link to spreadsheet!"
      endif
   else
      errormsg "Couldn't establish DDE link to Excel!"
   endif
 
FYI, be aware that data read from Excel will have a carrige return and line feed at the end of it that may cause you problems. You can use the commands strreplace szText "`n" "" and strreplace szText "`r" "" to strip these extra characters out.

 
Oh see, you're the man. They didn't teach that at Aspect programming school. What does that say about today's public education?

Seriously, thanks alot, everything is running fine now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top