如何将数据的多个部分保存到一个文本文件中? [英] How to save multiple parts of data to one text file?
问题描述
嘿,我正在做一个学校项目,我需要做的一件事就是创建一个程序,在其中可以存储姓名,性别,家教组,年龄,ID号(如何找到学生)还有25个学生的其他一些细节(总共8个).我真的很困惑 如何将所有详细信息输入到一个文本文件中,每行一位学生,请帮忙?
Hey there, I'm doing a project for school and one thing I need to do is create a program where I can store the name, gender, tutor group, age, ID number (how students are found) and a few more details (8 in total) for 25 students. I'm really confused on how to enter all the details into one text file, with one student per line, please help?
这是我到目前为止所拥有的:
this is what I have so far:
Dim Id As String = "" & NumericUpDown1.Value
Dim forename As String = TextBox1.Text
Dim surname As String = TextBox2.Text
Dim homeAdd As String = TextBox3.Text
Dim dateofbirth As String = DateTimePicker1.Text
Dim homeNum As String = TextBox4.Text
Dim tutorGroup As String = TextBox5.Text
Dim schoolEmail As String = TextBox6.Text
Dim gender As String = ComboBox1.Text
Dim record As String = Id & "," & forename & "," & surname & "," & homeAdd & "," & dateofbirth & "," & homeNum & "," & tutorGroup & "," & schoolEmail & "," & gender & vbNewLine
If Id = "" Or forename = "" Or surname = "" Or homeAdd = "" Or dOB = "" Or homeNum = "" Or tutorGroup = "" Or schoolEmail = "" Or gender = "" Then
MsgBox("input text")
Else
My.Computer.FileSystem.WriteAllText(filename, record, True)
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
TextBox6.Clear()
推荐答案
嘿,我正在做一个学校项目,我需要做的一件事就是创建一个程序,其中可以存储姓名,性别,家教组,年龄,ID号(如何找到学生)以及一些其他信息.更多细节(总共8个),可供25名学生使用.我真的很困惑 如何将所有详细信息输入到一个文本文件中,每行一位学生,请帮忙?
Hey there, I'm doing a project for school and one thing I need to do is create a program where I can store the name, gender, tutor group, age, ID number (how students are found) and a few more details (8 in total) for 25 students. I'm really confused on how to enter all the details into one text file, with one student per line, please help?
这是我到目前为止所拥有的:
this is what I have so far:
Dim Id As String = "" & NumericUpDown1.Value
Dim forename As String = TextBox1.Text
Dim surname As String = TextBox2.Text
Dim homeAdd As String = TextBox3.Text
Dim dateofbirth As String = DateTimePicker1.Text
Dim homeNum As String = TextBox4.Text
Dim tutorGroup As String = TextBox5.Text
Dim schoolEmail As String = TextBox6.Text
Dim gender As String = ComboBox1.Text
Dim record As String = Id & "," & forename & "," & surname & "," & homeAdd & "," & dateofbirth & "," & homeNum & "," & tutorGroup & "," & schoolEmail & "," & gender & vbNewLine
If Id = "" Or forename = "" Or surname = "" Or homeAdd = "" Or dOB = "" Or homeNum = "" Or tutorGroup = "" Or schoolEmail = "" Or gender = "" Then
MsgBox("input text")
Else
My.Computer.FileSystem.WriteAllText(filename, record, True)
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
TextBox6.Clear()
托比,
您真的可以在这里使用一个类-然后事情变得简单得多.
You could really use a class here - then things get a lot easier.
您学习过课程吗?
这篇关于如何将数据的多个部分保存到一个文本文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!