永发信息网

vb文件问题

答案:1  悬赏:40  手机版
解决时间 2021-08-11 00:43
  • 提问者网友:蓝莓格格巫
  • 2021-08-10 11:22

Private Sub Command1_Click()
If Text1.Text = "" And Text2.Text = "" Then
MsgBox "登录失败"
Text2.Text = ""
Else
Open "d:\a.txt" For Append As #1

Input #1, a, b

If Text1.Text = a And Text2.Text = b Then
MsgBox "登陆成功"
Text1.Text = ""
Text2.Text = ""
Else
MsgBox "登录失败"
End If
Close #1
End If
End Sub

Private Sub Command2_Click()
Me.Hide
Form2.Show

End Sub
Private Sub Command1_Click()
If Text1.Text = "" And Text2.Text = "" Then
MsgBox "注册失败"
Text1.Text = ""
Text2.Text = ""
Else
MsgBox "注册成功"
Open "D:\a.txt" For Append As #1
Write #1, Text1.Text, Text2.Text
Close #1
Text1.Text = ""
Text2.Text = ""
Me.Hide
Form1.Show
End If
End Sub
是这两段有问题,还是根本不能用文件来解决?

最佳答案
  • 五星知识达人网友:傲气稳了全场
  • 2021-08-10 12:45

Private Sub Command1_Click()



    If Text1.Text = "" And Text2.Text = "" Then



    MsgBox "登录失败"
    Text2.Text = ""



    Else



    Open "d:\a.txt" For input As #1



    Input #1, a, b



    If Text1.Text = a And Text2.Text = b Then
    MsgBox "登陆成功"
    Text1.Text = ""
    Text2.Text = ""
    Else
    MsgBox "登录失败"
    End If



    Close #1



    End If



End Sub



Private Sub Command2_Click()



    Me.Hide


    load form2
    Form2.Show



End Sub



Private Sub Command1_Click()



    If Text1.Text = "" And Text2.Text = "" Then



    MsgBox "注册失败"
    Text1.Text = ""
    Text2.Text = ""



    Else



    MsgBox "注册成功"
    Open "D:\a.txt" For Append As #1



    Write #1, Text1.Text, Text2.Text



    Close #1
    Text1.Text = ""
    Text2.Text = ""
    Me.Hide


    load form1
    Form1.Show



    End If



End Sub



代码已经帮你修改好了,在VB中进行文件操作的时候:



open filepath for input|output|append|binary|random as freefile()


‘其中用于输出写文件的有output,append,binary,random,用于输入读文件的有input,binary,random



input|line input|print|write|put|get filenumber, 变量列表


‘input,line input,get用于输入读文件操作


’print,write,put用于输出写文件操作



close



在进行窗体的切换操作的时候,显示一个窗体,需要先对窗体进行加载操作,然后再进行显示


load form_name


form_name.show



我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯