如果trim(ThisWorkbook.Sheets("sheet2").Cells(2, 1).Value)字符串是"hello world"
那么,那么下列语句应该是True:
"hello world" = trim(ThisWorkbook.Sheets("sheet2").Cells(2, 1).Value)
为了更好说明问题,举例:
sub TestStr()
ThisWorkbook.Sheets("sheet2").Cells(2, 1).Value="hello world"
if "hello world" = trim(ThisWorkbook.Sheets("sheet2").Cells(2, 1).Value) then msgbox "good"
dim a as string
a="hello world"
if a = trim(ThisWorkbook.Sheets("sheet2").Cells(2, 1).Value) then msgbox "good again"
end sub
那么(你的WORKBOOK中需要存在Sheet2)该程序运行就是,出现两个的对话框显示:"good", "good again"。