高分求高手帮忙做VB作业。我初学者、您做简单点就可以了。。急急急急急。。。
别告诉我该怎么做、我只需要哪位高手在短时间内帮忙做好就可以了。这是选修课的作业、老师的要求不是很高、随便做下就可以了做好了请发送至QQ邮箱:649962399@qq.co...
别告诉我该怎么做、我只需要哪位高手在短时间内帮忙做好就可以了。
这是选修课的作业、老师的要求不是很高、
随便做下就可以了
做好了请发送至QQ邮箱: 649962399@qq.com
先给100分、发送至邮箱后追分。。。
要求如下
编写程序,建立一个窗体,界面如下图所示。程序功能如下:
1、单击“读入”按钮,从顺序文件“test12.txt"中读入一个字符串显示在text1中;test12.txt文件自己建立文本文件。
2、单击”排序“按钮,将字符串按字母ascii码值从小到大排序,并显示在text1中
3、单击”追加“按钮时,将排序后生成的字符串添加到文件末尾。 展开
这是选修课的作业、老师的要求不是很高、
随便做下就可以了
做好了请发送至QQ邮箱: 649962399@qq.com
先给100分、发送至邮箱后追分。。。
要求如下
编写程序,建立一个窗体,界面如下图所示。程序功能如下:
1、单击“读入”按钮,从顺序文件“test12.txt"中读入一个字符串显示在text1中;test12.txt文件自己建立文本文件。
2、单击”排序“按钮,将字符串按字母ascii码值从小到大排序,并显示在text1中
3、单击”追加“按钮时,将排序后生成的字符串添加到文件末尾。 展开
2个回答
展开全部
已发送。
以下是窗体代码:(请用记事本保存为frm文件)
VERSION 5.00
Begin VB.Form fMain
BorderStyle = 3 'Fixed Dialog
ClientHeight = 2550
ClientLeft = 930
ClientTop = 525
ClientWidth = 4560
Icon = "fMain.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2550
ScaleWidth = 4560
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton cmdAppend
Caption = "追加"
Enabled = 0 'False
Height = 375
Left = 3000
TabIndex = 6
Top = 2040
Width = 1215
End
Begin VB.CommandButton cmdSort
Caption = "排序"
Enabled = 0 'False
Height = 375
Left = 1680
TabIndex = 5
Top = 2040
Width = 1215
End
Begin VB.CommandButton cmdInput
Caption = "读入"
Height = 375
Left = 360
TabIndex = 4
Top = 2040
Width = 1215
End
Begin VB.TextBox tSort
Height = 735
Left = 1560
Locked = -1 'True
MultiLine = -1 'True
TabIndex = 3
Top = 1080
Width = 2895
End
Begin VB.TextBox tInp
Height = 855
Left = 1560
Locked = -1 'True
MultiLine = -1 'True
TabIndex = 1
Top = 120
Width = 2895
End
Begin VB.Label Label2
Caption = "Sorted string"
Height = 255
Left = 120
TabIndex = 2
Top = 1080
Width = 1455
End
Begin VB.Label Label1
Caption = "Input string"
Height = 255
Left = 120
TabIndex = 0
Top = 120
Width = 1455
End
End
Attribute VB_Name = "fMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub cmdAppend_Click()
Open App.Path & "\test12.txt" For Append As #1
Print #1, tSort.Text
Close #1
End Sub
Private Sub cmdInput_Click()
Dim l As String, fs As String
If Len(Dir(App.Path & "\test12.txt")) = 0 Then
MsgBox App.Path & "\test12.txt 不存在!"
Exit Sub
End If
Open App.Path & "\test12.txt" For Input As #1
Do Until EOF(1)
Line Input #1, l
fs = fs & l & vbCrLf
Loop
Close #1
tInp.Text = fs
cmdSort.Enabled = True
cmdAppend.Enabled = True
End Sub
Private Sub cmdSort_Click()
'读入数组
Dim arr() As Integer, i As Long
ReDim arr(1 To Len(tInp.Text))
For i = 1 To UBound(arr)
arr(i) = Asc(Mid(tInp.Text, i, 1))
Next
'排序
Dim j As Long, t As Integer
For i = 1 To UBound(arr)
For j = 1 To UBound(arr)
If arr(i) < arr(j) Then
t = arr(i)
arr(i) = arr(j)
arr(j) = t
End If
Next
Next
'恢复
For i = 1 To UBound(arr)
tSort.Text = tSort.Text & Chr(arr(i))
Next
End Sub
以下是窗体代码:(请用记事本保存为frm文件)
VERSION 5.00
Begin VB.Form fMain
BorderStyle = 3 'Fixed Dialog
ClientHeight = 2550
ClientLeft = 930
ClientTop = 525
ClientWidth = 4560
Icon = "fMain.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2550
ScaleWidth = 4560
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton cmdAppend
Caption = "追加"
Enabled = 0 'False
Height = 375
Left = 3000
TabIndex = 6
Top = 2040
Width = 1215
End
Begin VB.CommandButton cmdSort
Caption = "排序"
Enabled = 0 'False
Height = 375
Left = 1680
TabIndex = 5
Top = 2040
Width = 1215
End
Begin VB.CommandButton cmdInput
Caption = "读入"
Height = 375
Left = 360
TabIndex = 4
Top = 2040
Width = 1215
End
Begin VB.TextBox tSort
Height = 735
Left = 1560
Locked = -1 'True
MultiLine = -1 'True
TabIndex = 3
Top = 1080
Width = 2895
End
Begin VB.TextBox tInp
Height = 855
Left = 1560
Locked = -1 'True
MultiLine = -1 'True
TabIndex = 1
Top = 120
Width = 2895
End
Begin VB.Label Label2
Caption = "Sorted string"
Height = 255
Left = 120
TabIndex = 2
Top = 1080
Width = 1455
End
Begin VB.Label Label1
Caption = "Input string"
Height = 255
Left = 120
TabIndex = 0
Top = 120
Width = 1455
End
End
Attribute VB_Name = "fMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub cmdAppend_Click()
Open App.Path & "\test12.txt" For Append As #1
Print #1, tSort.Text
Close #1
End Sub
Private Sub cmdInput_Click()
Dim l As String, fs As String
If Len(Dir(App.Path & "\test12.txt")) = 0 Then
MsgBox App.Path & "\test12.txt 不存在!"
Exit Sub
End If
Open App.Path & "\test12.txt" For Input As #1
Do Until EOF(1)
Line Input #1, l
fs = fs & l & vbCrLf
Loop
Close #1
tInp.Text = fs
cmdSort.Enabled = True
cmdAppend.Enabled = True
End Sub
Private Sub cmdSort_Click()
'读入数组
Dim arr() As Integer, i As Long
ReDim arr(1 To Len(tInp.Text))
For i = 1 To UBound(arr)
arr(i) = Asc(Mid(tInp.Text, i, 1))
Next
'排序
Dim j As Long, t As Integer
For i = 1 To UBound(arr)
For j = 1 To UBound(arr)
If arr(i) < arr(j) Then
t = arr(i)
arr(i) = arr(j)
arr(j) = t
End If
Next
Next
'恢复
For i = 1 To UBound(arr)
tSort.Text = tSort.Text & Chr(arr(i))
Next
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询