Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Loops 在vb.net中循环数据结构并比较值_Loops_Data Structures_Compare_Vb.net 2010 - Fatal编程技术网

Loops 在vb.net中循环数据结构并比较值

Loops 在vb.net中循环数据结构并比较值,loops,data-structures,compare,vb.net-2010,Loops,Data Structures,Compare,Vb.net 2010,这是非常重要的 情况: 我正在建立一个注册设施的“游戏”。我使用的是数据结构和数组。我已经有了我所需要的一切,但登录。我需要一个循环,它将: 循环遍历数组/记录 将数组/记录中的内容与用户在文本框中输入的内容进行比较 运行其他代码 以下是我的存储方法: Public Structure typRegistrationDetails Dim strUsername As String Dim strPassword As String End Structure Public

这是非常重要的

情况: 我正在建立一个注册设施的“游戏”。我使用的是数据结构和数组。我已经有了我所需要的一切,但登录。我需要一个循环,它将:

  • 循环遍历数组/记录
  • 将数组/记录中的内容与用户在文本框中输入的内容进行比较
  • 运行其他代码
以下是我的存储方法:

Public Structure typRegistrationDetails
    Dim strUsername As String
    Dim strPassword As String
End Structure

Public Shared strUsers(0 To 2) As typRegistrationDetails
用户数量目前限制为3个;每个strUsers包含strUsername和strPassword

我已经写了注册代码,如果你需要看,请告诉我

现在,我需要一个循环来循环上述结构,并将它们的值与用户输入的值进行比较

我的意思是,如果txtsername.Text(用户输入)和txtspassword.Text(用户输入)与struser(索引)中的一个匹配,那么就做些什么,或者做些别的什么。

类似的事情

Dim found As Boolean = False
For Each u As typRegistrationDetails In strUsers
    If u.strUserName = strUserName AndAlso
       u.strPassword = strPassword Then
        found = True
        Exit For
    End If
Next
If found Then
    ' do something
Else
    ' do something else
End If