登錄站點

用戶名

密碼

detect if a string in an array

2已有 240 次閱讀  2017-02-04 06:55   標籤Object  Error 
Option Explicit On
Public Class Form1
    Public Function IsInArray(ByVal FindValue As Object, ByVal arrSearch As Object) As Boolean
        On Error GoTo LocalError
        If Not IsArray(arrSearch) Then Exit Function
        If Not IsNumeric(FindValue) Then FindValue = UCase(FindValue)
        IsInArray = InStr(1, vbNullChar & Join(arrSearch, vbNullChar) & vbNullChar, _
     vbNullChar & FindValue & vbNullChar) > 0
        Exit Function
LocalError:
        'Justin (just in case)
    End Function
    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        Try
           Dim mypoc() As String = {"色調", "飽和度計算", "mspaint", "calc", "notepad"}
            Dim Shipping As String = TextBox1.Text
            For Each a As String In mypoc
                If Shipping = a Then
                    MsgBox("true")
                End If
            Next
        Catch ex As Exception
        End Try
    End Sub
分享 舉報