注册 登录
编程论坛 VB6论坛

vb中未设置对象变量或with块变量怎么解决?

anniegao 发布于 2018-05-27 23:28, 1603 次点击
Public Class frmLogin
    Dim cnt As Integer
    Dim fd As Integer

    Private Property CM As Object

    Private Sub frmLogin_Load(ByVal sender As System.Object,
                                  ByVal e As System.EventArgs) Handles MyBase.Load
        Me.UserTableAdapter.Fill(Me.CourtMDataSet.UserInformation)
        Cbotype.SelectedIndex = 0
        If userID = "" Then
            cnt = 0
            txtuser.Text = "csu"
            txtpwd.Text = "csu"
        End If
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object,
                              ByVal e As System.EventArgs) Handles Button1.Click
        cnt = cnt + 1
        If cnt = 3 Then
            End
        End If
        If Trim(txtuser.Text) = "" Then
            MsgBox("请输入用户名", vbOKOnly + vbExclamation, "")
            Exit Sub
        End If
        fd = UserBindingSourse.Find("username", Trim(txtuser.Text))
        If fd = -1 Then
            MsgBox("没有这个用户", vbOKOnly + vbExclamation, "")
            Exit Sub
        End If
        UserBindingSourse.Position = fd
        If Trim(UserBindingSourse.Current(2).ToString) <> Trim(Cbotype.Text) Then
            MsgBox("没有符合条件的用户", vbOKOnly + vbExclamation, "")
            Exit Sub
        End If
        If Trim(UserBindingSourse.Current(1).ToString) = Trim(txtpwd.Text) Then
            userID = txtuser.Text
            If Trim(Cbotype.Text) = "管理员" Then
                usertype = 1
            Else
                usertype = 2
            End If
            Me.Dispose()
            CM.vbMain.Show()
        Else
            MsgBox("密码不正确", vbOKOnly + vbExclamation, "")
            Exit Sub
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object,
                              ByVal e As System.EventArgs) Handles Button2.Click
        Me.Dispose()
    End Sub


    Private Sub Cbotype_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub Cbotype_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub txtuser_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cbotype.SelectedIndexChanged

    End Sub

    Private Function UserBindingSourse() As Object
        Me.Hide()
        CMFrmMain.Show()
    End Function

End Class

大学要做的课程设计
因为没学所以是抄书上的代码
它报错我完全不懂。。
是红色那一句出了问题fd = UserBindingSourse.Find("username", Trim(txtuser.Text))这个
求解决啊。。跪求
1 回复
#2
ZHRXJR2018-05-28 20:08
fd = UserBindingSourse.Find("username", Trim(txtuser.Text))
估计你的窗体没有 txtuser.Text 控件
1