Visual Basic 2010(我不知道什么是错的)代码无效 [英] Visual basic 2010 (I don't know whats wrong) code is not working

查看:71
本文介绍了Visual Basic 2010(我不知道什么是错的)代码无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Dim R As IO.StreamReader
    Dim LogInSom As String
    Dim Navn As String
    Dim Kode As String
    Dim OKnavn As Boolean
    Dim Kode2 As String
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Navn = InputBox("Write your username")
        Dim directorry = "C:\Klub-Oversigt\Spillere\"
        Dim filees() As System.IO.FileInfo
        Dim dirinffo As New System.IO.DirectoryInfo(directorry)
        filees = dirinffo.GetFiles("*", IO.SearchOption.AllDirectories)
        For Each file In filees
            If Navn Is filees Then
                OKnavn = True
                Exit For
            Else

                OKnavn = False

            End If
        Next
        Kode = InputBox("Write your pass")

        If OKnavn = True Then
            R = New IO.StreamReader("C:\Klub-Oversigt\Spillere\" & Navn & ".txt")
            Kode2 = R.ReadToEnd()
            R.Close()
            If Kode Is Kode2 Then
                MsgBox("Kode og brugernavn accepteret!", MsgBoxStyle.Information)
            Else
                MsgBox("Wrong pass!")
            End If
        Else
            MsgBox("Wrong username." & Chr(13) & "Hvis du er sikker på du har skrevet rigtigt, kan du være banned", MsgBoxStyle.Critical, "Fejl!")
            End
        End If





每次运行程序并写入用户名并通过时,是显示错误的用户名msgbox?



Every time i run the program and write username and pass, is displays the "Wrong username" msgbox?

推荐答案

For Each file In filees
    If Navn Is filees Then
        OKnavn = True
        Exit For
    Else

        OKnavn = False

    End If
Next



您正在比较 Navn 文件这是一个数组;你应该将它与文件进行比较。我建议您查看您对变量名称的选择,以使代码更加模糊。


You are comparing Navn against filees which is an array; you should be comparing it against file. I would suggest reviewing your choice of variable names to make your code less ambiguous.


这篇关于Visual Basic 2010(我不知道什么是错的)代码无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆