vb记录集数据导入到excel
Public Sub DGToExcel(DataGrid1 As DataGrid, Optional ProgressBar1 As ProgressBar, Optional ByVal intFirst As Integer, Optional ByVal intLast As Integer, Optional strTitle As String)
'--将DataGrid导出至Excel,ProgressBar1为进度条,intFirst为从哪一列开始打印,intLast为打印到哪一列
On Error Resume Next
Dim I As Long
Dim J As Integer
Dim K As Integer
Dim sLast As String
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Set xlApp = New Excel.Application
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
xlSheet.Name = "查询结果"
xlApp.Visible = False '--先隐藏
ProgressBar1.Value = 0
Screen.MousePointer = 11
ProgressBar1.Max = DataGrid1.ApproxCount + 3
'--设置标题
sLast = Chr(Asc("A") + intLast - intFirst)
xlApp.Range("A1:" & sLast & "2").Select
With xlApp.Selection '--合并单元格
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
ProgressBar1.Value = 1
xlApp.Selection.Merge
With xlApp.Selection.Font '--字体
.FontStyle = "加粗"
.SIZE = 24
End With
xlApp.Range("A1:" & sLast & "2").Select
xlApp.ActiveCell.FormulaR1C1 = strTitle
ProgressBar1.Value = 2
'--设置列
For K = 0 To intLast - intFirst '显示选中的列
相关文档:
VB中 Replace 函数
描述
返回字符串,其中指定数目的某子字符串被替换为另一个子字符串。
语法
Replace(expression, find, replacewith[, compare[, count[, start]]])
Replace 函数的语法有以下参数:
参数 描述
expression 必选。字符串表达式,包含要替换的子字符串。
find 必选。被搜索的子字符串。
......
开始使用vb的时候喜欢用手画出那个控件的位置.然后一个一个的拖动,一点一点的移动.直到感觉满意了为止.如果是控件多了这个就很麻烦了
一不小心可能会将谋个控件拖到一边去
所以,我们在以后的作品中
尽量使用代码来定义控件位置,,要灵活的掌握坐标位置.,可以使用自定义坐标.使用像素来更好的来分区显示控件.
& ......
添加2个text,一个command,一个 WebBrowser
Dim vDoc, vTag
Dim i As Integer
Private Sub Command1_Click()
Set vDoc = WebBrowser1.Document
For i = 0 To vDoc.All.length - 1
If UCase(vDoc.All(i).tagName) = "INPUT" Then
Set vTag = vDoc.All(i)
If vTag.Type = "text" Then
Select Case vTag.Nam ......
Option Explicit
Public Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Public Declare Function RegCreateKey Lib "advapi32.dll" Alias ......
http://www.carlosag.net/Tools/CodeTranslator/ 这个也许学计算机的哥哥姐姐们会用得到,,就转了希望多多支持哦 西西 用得到就顶哦
差点忘了哦 ,藕还有一个sql的插件很好用的呀。。。。有想要的就留言下要咯。。。。。 ......