十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
这里有段VB6.0的,你可以参考。
站在用户的角度思考问题,与客户深入沟通,找到广安网站设计与广安网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:成都网站建设、成都网站制作、企业官网、英文网站、手机端网站、网站推广、域名与空间、虚拟空间、企业邮箱。业务覆盖广安地区。
注意添加引用。
Private Sub Command6_Click()
Dim i, j As Integer
Dim xlApplication As Excel.Application, xlWorkbook As Excel.Workbook, xlSheet
Dim xlApp As Excel.Application
On Error Resume Next
Set xlApplication = GetObject(, "渗运Excel.Application")
Set xlApp = CreateObject("Excel.Application")
If MsgBox("确认将文件信息导出到EXCEL中?�", vbExclamation + vbYesNo, "警告") = vbYes Then
If Err.Number 0 Then Set xlApplication = CreateObject("Excel.Application")
Set xlWorkbook = xlApplication.Workbooks.Add
Set xlSheet = xlWorkbook.ActiveSheet
xlSheet.Cells(1, 2) = lblcl.Caption
xlSheet.Range("A1:E1").MergeCells = True
xlSheet.Range("A1:E1").HorizontalAlignment = xlCenter
xlSheet.Cells(2, 2).ColumnWidth = 18
For i = 1 To DataGrid1.Columns.Count
xlSheet.Cells(2, 1) = "槐喊拍编号"
xlSheet.Cells(2, i + 1) = DataGrid1.Columns(i).Caption
For j = 0 To DataGrid1.VisibleRows - 1
xlSheet.Cells(j + 3, 1) = j + 1
xlSheet.Cells(j + 3, i + 1) = DataGrid1.Columns(i).CellText(DataGrid1.RowBookmark(j))
Next j
Next i
xlApplication.Visible = True
Set xlSheet = Nothing
Set xlWorkbook = Nothing
Set xlApplication = Nothing
'xlApp.Range("A2:L2").Columns.Interior.ColorIndex = 40
'xlApp.Range("A2:L2").Borders.LineStyle = xlContinuous
'xlApp.Visible = True
'xlApp.Range(xlSheet.Cells(2 + PartsRs.RecordCount + 1, 1), xlSheet.Cells(2 + PartsRs.RecordCount + 1, 8)).Columns.Interior.ColorIndex = 40
'xlApp.Range(xlSheet.Cells(2 + PartsRs.RecordCount + 1, 1), xlSheet.Cells(2 + PartsRs.RecordCount + 1, 8)).Borders.LineStyle = xlContinuous
Else
MsgBox "无信息可供您导出,请确铅羡认!", vbExclamation + vbOKOnly, "警告"
End If
End Sub
以下示例一次从文件中读取一行首族,然后迹前将每行文本姿芹清打印到控制台。
Sub ReadTextLinesFromFile()
Dim file As New System.IO.StreamReader("c:test.txt")
Dim oneLine As String
oneLine = file.ReadLine()
While (oneLine "")
Console.WriteLine(oneLine)
oneLine = file.ReadLine()
End While
file.Close()
End Sub
方法1:
Open "c:\1.txt" For Output As #1 '裤键c:\1.txt为保存文件
Print #1, Text1 Text2 Text3 ..... '将多个文本框内容用合并在一起 写入内容
Close #1 '关贺脊闭文件
方法2:
Dim aa As String
aa =Text1 Text2 Text3 ..... '将多个文本框内容用合并到变量aa
Open "c:\1.txt"胡拍巧 For Output As #1 'c:\1.txt为保存文件
Print #1, aa '写入内容
Close #1 '关闭文件
首先执行Sub Main()
①定义两个变量a=45 b=18
②将a和b作为sum过程的两个参数x=45(按值传递),y=18(按地址传递,将在过程中改变b的初始值)
③xy满足条件,将 x-y=45-18=27 赋值给衡皮桐x ;将 x+y=27+18=45 赋值给y,此时改变了b值为咐坦45.
④输出x的值27 y的值45
⑤输出a的值45 b的值握困45