Private Sub Button1_Click(ByVal sender As SystemObject, ByVal e As SystemEventArgs) Handles Button1Click
Dim opfile As New OpenFileDialog '声名新open 窗口
Dim filetmp() As String '存文件名
opfileFilter = "文本文件(txt)|txt|所有文件()|" '添加过滤文件
opfileMultiselect = True '多开文件打开
If opfileShowDialog = WindowsFormsDialogResultOK Then '如果打开窗口OK
If opfileFileName <> "" Then '如果有选中文件
ReDim filetmp(opfileSafeFileNamesLength)
filetmp = opfileSafeFileNames '取文件名
For i As Integer = 0 To filetmpLength - 1
ListBox1ItemsAdd(filetmp(i)) '添加文件名
Next
End If
End If
End Sub分类: 电脑/网络 >> 程序设计 >> 其他编程语言
问题描述:
Private Sub Command2_Click()
Dim objExcel
Set objExcel = GetObject("F:\dj1xls") '连接已打开的excel文件
Set objsheet = objExcelWorksheets("sheet2")
objsheetCells(1, 1) = "hghdgsgds" '往sheet2的单元格写入hello成功
objworkbookSheetsAdd After:=objExcelWorksheets(1) '插入新sheet失败,错误提示:要求对象
End Sub
请大侠指点!
解析:
objworkbookSheetsAdd After:=objExcelWorksheets(1) '插入新sheet失败,
这里的 objworkbook 不对吧。
该成 objExcel 试试吧。Private Sub cmd1_Click()
dim temp as string
dim ls() as string
dim i as integer
temp=inputbox("Input please!")
ls=split(temp,",")
for i=lbound(ls) to ubound(ls)
list1additem ls(i)
next
msgbox "Ok,Over!"
End sub定义一个窗体继承自SystemWindowsFormsForm。
添加以下控件对象到窗体:
Private folderBrowserDialog1 As SystemWindowsFormsFolderBrowserDialog
Private button1 As SystemWindowsFormsButton
Private listBox1 As SystemWindowsFormsListBox
给button1的Click事件添加以下处理程序:
Sub Button1Click(sender As Object, e As EventArgs)
If SystemWindowsFormsDialogResultOK=MefolderBrowserDialog1ShowDialog(Me) Then
MelistBox1ItemsAddRange(SystemIODirectoryGetFiles(MefolderBrowserDialog1SelectedPath))
End If
End SubPrivate Sub Command1_Click()
Dim str As String
Open "c:\wangzhitxt" For Input As #1
Do While Not EOF(1)
Line Input #1, str
List1AddItem str
Loop
Close
End Sub
c:\wangzhitxt,改为你的txt文件名称及路径
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)