0

i have a problem with VisualBasic6 .

i have 3 Textbox and 2 Command Button .

i want to detect VbCrLf when checking first textbox , letter by letter then write in another in second textbox: 101 and another function check the second textbox , if found 101 then make a new line (vbcrlf) in the third textbox.

in a Command :

For i = 1 to len(text1.text)
   if Mid(txtD.Text, i, 1) = vbcrlf then
      text2.text = 101
   endif
next

in Command2 :

if text2.text = 101 then
  text3.text = text3.text & vbcrlf
endif

but when i check for Vbcrlf , it seem that character is not a newline-character and text2.text doesn't fill 101

Also i tried VbNewLine but there is same problem !

Thank You my friends !

4

1 回答 1

5

您需要准确检查新行分隔符是什么。我见过 vbcr、vblf 和 vbcrlf。VbNewLine 与 vbcrlf 相同。

此外,即使您的字符串中有 vbcrlf,您的测试仍然会失败。vbcrlf 是两个字符。您一次只测试一个角色。

更好的测试是 InStr() 函数。这是一个快速测试,看看较小的字符串是否在较大的字符串中的任何位置。因此,您的测试将如下所示:

If InStr(txtD.Text, vbcr) or InStr(txtD.Text, vblf) then
  text2.text = 101
End If
于 2013-04-22T19:37:50.243 回答