求用VB做一个查成绩的程序,谢谢 100
2个回答
展开全部
'数据文件名称 = cj.dat
'数据类型 = ini类型
'[成绩]
'学生姓名=学科1成绩,学科2成绩,...,学科n成绩
'界面设计:
'1个Label,Caption="姓名";1个TextBox,用户输入要查询的学生姓名,Name="Text1",Text="";1个CommandButton,Name="Command1",Caption="查询成绩"
'
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Const km="科目1,科目2,科目3,科目4,科目5" '需根据实际情况更改
Private Sub Text1_GotFocus()
Text1 = ""
End Sub
Private Sub Command1_Click()
Dim buf, rt As Long, n As Long, xk, i As Integer, msg As String
n = 256 '需根据实际情况更改这个数字的大小
buf = Space(n)
rt = GetPrivateProfileString("成绩",Text1.Text, "", buf, n, App.Path & "\cj.dat")
If rt = 0 Then
MsgBox "未找到”" & Text1.Text & "“的成绩!"
Else
buf = Split(buf, vbNullChar)
xk = Split(km,",")
msg = xk(0) & " = " & buf(0)
For i = 1 To UBound(xk)
msg = msg & "," xk(i) & " = " & buf(i)
Next
MsgBox Text1.Text & "的成绩:" & vbCrlf & msg
End If
End Sub
'数据类型 = ini类型
'[成绩]
'学生姓名=学科1成绩,学科2成绩,...,学科n成绩
'界面设计:
'1个Label,Caption="姓名";1个TextBox,用户输入要查询的学生姓名,Name="Text1",Text="";1个CommandButton,Name="Command1",Caption="查询成绩"
'
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Const km="科目1,科目2,科目3,科目4,科目5" '需根据实际情况更改
Private Sub Text1_GotFocus()
Text1 = ""
End Sub
Private Sub Command1_Click()
Dim buf, rt As Long, n As Long, xk, i As Integer, msg As String
n = 256 '需根据实际情况更改这个数字的大小
buf = Space(n)
rt = GetPrivateProfileString("成绩",Text1.Text, "", buf, n, App.Path & "\cj.dat")
If rt = 0 Then
MsgBox "未找到”" & Text1.Text & "“的成绩!"
Else
buf = Split(buf, vbNullChar)
xk = Split(km,",")
msg = xk(0) & " = " & buf(0)
For i = 1 To UBound(xk)
msg = msg & "," xk(i) & " = " & buf(i)
Next
MsgBox Text1.Text & "的成绩:" & vbCrlf & msg
End If
End Sub
更多追问追答
追问
没数据库?
要把成绩单搞上去
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询