简体   繁体   English

如果条件让我发疯

[英]If condition is driving me crazy

Please I need help... two identical strings are not returning $True when checking on IF logical statement. 我需要帮助......当检查IF逻辑语句时,两个相同的字符串不返回$ True。

The images illustrates perfectly my frustration. 这些图片完全说明了我的挫败感。 I'm starting with GUIs don't be cruel please. 我开始使用GUI并不是很残忍。

I've tried checking with label text with variables from textbox.text everything that came to my mind... 我试过用textbox.text中的变量检查带有变量的标签文本。

blob: https://imgur.com/5fcdabfb-b86e-436d-9c57-ed5f97c48229 blob: https//imgur.com/5fcdabfb-b86e-436d-9c57-ed5f97c48229


        Write-Host "$Udrive\$($comboSamaccount.Text)"
        Write-Host "$Homedirectory"
        $Udriveinfo = "$Udrive\$($comboSamaccount.Text)"
        $labeUdriveINFO.Text = $Udriveinfo
        $labeUdriveINFO.Text -eq "$Homedirectory"
        if ("$Udrive\$($comboSamaccount.Text)" -eq "$Homedirectory")
        {
            $Ud = "The U drive is - OK"
        }
        else
        {
            $Ud = "The U drive must be changed to $Udrive\$($comboSamaccount.Text)"
        }
    }

Thanks in advance. 提前致谢。

Best regards. 最好的祝福。

For the purposes of troubleshooting this, I'd do the following: 出于解决此问题的目的,我将执行以下操作:

$a = "$Udrive\$($comboSamaccount.Text)"
$b = "$Homedirectory"
for($i = 0; $i -lt $a.Length; $i++)
{
  if("$($a[$i])" -ne "$($b[$i])"){
    Write-Host 'Mismatch found' -ForegroundColor Red
    Write-Host ('[{4:D2}] {0}:{1:X} - {2}:{3:X}' -f $a[$i],(+$a[$i]),$b[$i],(+$b[$i]),$i)
  }
}

This will go through the characters in the strings one by one and try to find the ones that aren't the same 这将逐个查看字符串中的字符,并尝试找到不相同的字符

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM