VB,如何检查某个字符是否在字符串中

时间:2015-09-16 02:56:12

标签: vb6

好的,在visual basic中我试图从一个文件读入,我需要读的唯一内容是所有字符串,它们的末尾有一个°因为它是一个温度。到目前为止,我有它所以整数将被读入,但我不知道如何检查它是否有一个°的结尾。这就是我所拥有的:

Public Function getNextInteger() As Integer

    Dim charInt As String
    Dim chr As String
    Static index As Integer = -1
    index += 1
    chr = numDat(index)

    While Asc(chr) < 48 Or Asc(chr) > 57
        index += 1
        chr = numDat(index)
    End While

    charInt = chr

    While Asc(chr) >= 48 And Asc(chr) <= 57
        index += 1
        chr = numDat(index)
        charInt += chr
    End While

    Return CInt(charInt)

End Function

谢谢!

1 个答案:

答案 0 :(得分:0)

你的意思是?

Dim txt As String
txt = "55°"
If Len(txt) > 0 And Right(txt, 1) = "°" Then MsgBox "° found"

If Len(txt) > 0 And Asc(Right(txt, 1)) = 176 Then MsgBox "° found"