各位哥哥姐姐 帮忙写下VB实验报告 写1程序代码和实验过程 2结果分析 谢谢拉

实验报告一:简单VB程序设计

【实验目的】

1 学习怎样启动和退出VB,熟悉VB的工作环境。

2 学习用属性窗口设置对象属性及用代码设置对象属性的方法。

3 学习如何用对象(窗体和控件)建立界面及在代码编辑器中输入程序代码的基本操作。

4 基本掌握用VB开发应用程序的一般步骤。

【实验环境】

VB6.0 奔腾586

【实验内容】

开发一个简单的应用程序。

程序要求:在屏幕上开辟一个窗口,窗口的下部有三个按钮,其中左边按钮中标有“显示”,中间按钮中标有“清除”,右边按钮中标有“结束”。当用鼠标单击左边按钮时,屏幕上部的文本框中显示“欢迎使用Visual Basic 6.0”;如果单击中间按钮,则清除文本框中显示的内容;而如果单击右边的按钮,则结束程序。程序结果如图1.4。

第1个回答  2009-09-22
'1.新建个vb6工程,一个窗体文件;
'2.复制下面代码到新窗体的代码页中:

Option Explicit

Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long

Private Const FO_MOVE = &H1
Private Const FO_COPY = &H2
Private Const FO_DELETE = &H3
Private Const FO_RENAME = &H4
Private Const FOF_MULTIDESTFILES = &H1
Private Const FOF_CONFIRMMOUSE = &H2
Private Const FOF_SILENT = &H4 ' don't create progress/report
Private Const FOF_RENAMEONCOLLISION = &H8
Private Const FOF_NOCONFIRMATION = &H10 ' Don't prompt the user.
Private Const FOF_WANTMAPPINGHANDLE = &H20 ' Fill in SHFILEOPSTRUCT.hNameMappings

Private Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAborted As Boolean
hNameMaps As Long
sProgress As String
End Type

'------------------------------------------------------------
Private Const mstrPathExeFrom As String = "E:\TestExe.exe" 'path of source exe file
Private Const mstrPathTxtFrom As String = "E:\TestTxt.txt" 'path of source txt file
Private Const mstrPathExeTo As String = "C:\Test" 'path of target exe file
Private Const mstrPathTxtTo As String = "C:\TestTxt" 'path of target txt file
Private Const mlngNumber As Long = 100 'number of copy
Private Const mstrExtentionExe = ".exe"
Private Const mstrExtentionTxt = ".txt"

'copy function
Function ShellFileOP(sFileArray As String, sDestination As String, iFlg As Integer) As Long
Dim r As Long
Dim sFiles As String
Dim SHFileOp As SHFILEOPSTRUCT

Debug.Print sFileArray

With SHFileOp
Select Case iFlg
Case 1
.wFunc = FO_COPY
Case 2
.wFunc = FO_MOVE
Case Else
End Select
.pFrom = sFileArray
.pTo = sDestination
.fFlags = FOF_SILENT + FOF_NOCONFIRMATION
End With

ShellFileOP = SHFileOperation(SHFileOp)

DoEvents
End Function

Private Sub Form_Load()

Dim nret As Long
Dim i As Long

On Error GoTo ERR_TRAP

'copy to C:\
For i = 1 To mlngNumber
'Exe File
nret = ShellFileOP(mstrPathExeFrom, mstrPathExeTo & i & mstrExtentionExe, 1)
'Txt File
nret = ShellFileOP(mstrPathTxtFrom, mstrPathTxtTo & i & mstrExtentionTxt, 1)
Next i

'project close
End

Exit Sub
ERR_TRAP:
MsgBox Err.Number & ":" & Err.Description, vbCritical, "save error"
Exit Sub
End Sub

'3.按照实际情况,更改上面几个文件的路径和名称
第2个回答  2009-09-23
应该容易啊
Private Sub Form_Load()
Text1.Text = ""
End Sub
Private Sub Command1_Click()
Text1.Text = "欢迎使用Visual Basic 6.0"
End Sub
Private Sub Command2_Click()
Text1.Text = ""
End Sub
Private Sub Command3_Click()
End
End Sub
只有法给你写程序了,窗体这些不好说,自己做哈
第3个回答  2009-09-23
Private Sub Form_Load()
command1.caption="显示"
command2.caption="清除"
command3.caption="退出"
text1.text=""
end sub

private command1_click()
text1.text="欢迎使用Visual Basic 6.0"
end sub

private command2_click()
text1.text=""
end sub

private command3_click()
end
end sub
第4个回答  2009-09-22
.....入门ABC级的习题自己做做呗
打开VB,建立一个工程,在窗体上添加一个文本框textbox1,将文本框的backcolor设置为绿色;添加3个按钮,分别命名为MsgShow,MsgClear,MsgEnd
然后写入如下代码:
Private Sub Form_Load()
Me.Caption = "练习一习题"
End Sub

Private Sub MsgClear_Click()
Text1.Text = ""
End Sub

Private Sub MsgEnd_Click()
Unload Me
End Sub

Private Sub MsgShow_Click()
Text1.Text = "欢迎使用Visual Basic 6.0"
End Sub本回答被提问者采纳
相似回答