返回目录:excel表格制作
今天我为大家讲解下,如何用EXCEL自动同步下载大乐透、双色球、3d、排列5、7乐彩等彩票开奖信息。
一、效果展示
效果展示
如上图,可以看到,当我们点击双色球按钮后,excel会自动从网上下载更新双色球开奖信息。喜欢玩彩票的朋友可以通过该excel下载彩票开奖信息后,方便进行分析和筛选。
二、功能讲解
1、窗体制作
进入VBA开发界面
添加按钮、标签、框架等
如上图,我们通过开发工具进入VBA开发界面,插入窗体后,通过工具箱在窗体中添加按钮、标签、框架等,就像绘画一样,把这些元素绘制到该窗体上,此时这些元素没有任何功能,因为我们还没有编程。
2、汇编编程
使用界面
窗体上,各个按钮下对命令基本相似,我们以双色球按钮下的程序语言大致给大家讲解下。
Private Sub CommandButton1_Click()
Range("A2:AV10000").Clear
k3dshijihao = "http://e.17500.cn/getData/ssq.TXT"
d3s = "WData3D_All"
Sheets(1).Cells(3, 1).Select '冻结窗口
ActiveWindow.FreezePanes = True '冻结窗口
Cells(1, 1).Interior.ColorIndex = 48 '将单元格的背景色设置为灰色
Cells(1, 1) = "双色球"
Sheets(1).Name = "双色球"
Cells(2, 1) = "开奖期号"
Cells(2, 2) = "开奖日期"
Cells(2, 3) = "红"
Cells(2, 4) = "号"
Cells(2, 5) = " "
Cells(2, 6) = " "
Cells(2, 7) = " "
Cells(2, 8) = " "
Cells(2, 9) = "蓝"
Cells(2, 10) = "红"
Cells(2, 11) = "号"
Cells(2, 12) = "出"
Cells(2, 13) = "球"
Cells(2, 14) = "顺"
Cells(2, 15) = "序"
Cells(2, 16) = "投注总额"
Cells(2, 17) = "奖池金额"
Cells(2, 18) = "一等注数"
Cells(2, 19) = "一等金额"
Cells(2, 20) = "二等注数"
Cells(2, 21) = "二等金额"
Cells(2, 22) = "三等注数"
Cells(2, 23) = "金额"
Cells(2, 24) = "四等注数"
Cells(2, 25) = "金额"
Cells(2, 26) = "五等注数"
Cells(2, 27) = "金额"
Cells(2, 28) = "六等注数"
Cells(2, 29) = "金额"
cz = k3dshijihao: czmc = d3s
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & cz, Destination:=Range("A3"))
.Name = czmc
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = True
.TextFileColumnDataTypes = Array(1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Sheet1.Name = "双色球"
Range("A" & (Application.Count(Range("a1:a3000")))).Select
End
End Sub
现截取程序片段给大家简单讲解下,CommandButton1_Click(),按钮1的单击事件,即单击“双色球”按钮时执行该程序;k3dshijihao = http://e.17500.cn/getData/ssq.TXT,从该网址获取数据;Cells(1, 1) = "双色球",Cells(1, 1)是代表第一行第一列单元格,即A1单元格被赋值“双色球”,其余的Cells(2, 1)、Cells(2, 2)等同理;Sheets(1).Name = "双色球",是将表1(Sheet1),重命名为双色球;Range("A2:AV10000").Clear,将excel表区域A2:AV10000清空。
汇编语言就为大家讲解到这里,这个程序比较简单,基础好的很容易看懂,没有基础或薄弱的可能会有困难,不用非得一下子就把它看懂学明白,每次学上一点,慢慢的大家就会融会贯通。
总结:该彩票更新功能主要用到VBA汇编语言,我们学好VBA后,对我们后期学习VB有很大帮助。千里之行始于足下!今天就为大家讲解到这里,希望能与大家一起学习成长!