最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

獲取股票實(shí)時行情數(shù)據(jù) Access數(shù)據(jù)庫系統(tǒng)功能講解VBA代碼編程實(shí)例

2022-07-03 22:01 作者:凌霄百科  | 我要投稿




Private Sub Command查詢_Click()

If Me.查詢股票代碼 <> "" Then

Dim scode As String

scode = Me.查詢股票代碼

? ? If IsNumeric(scode) = False Then

? ? MsgBox "請輸入正確股票代碼"

? ? Exit Sub

? ? End If

Else

Exit Sub

End If

Call 獲取并顯示股票數(shù)據(jù)(scode)

End Sub



Public Function getstockbasicdatafun(ByVal codetext As String) As String

? ? Dim url As String? ?'數(shù)據(jù)獲取地址

? ? If codetext <> "" Then

? ? ? ? url = "http://qt.gtimg.cn/q=" & codetext

? ? ? ? With CreateObject("msxml2.XMLHTTP")

? ? ? ? ? ? .Open "get", url, False

? ? ? ? ? ? .Send

? ? ? ? ? ?If UBound(Split(.responsetext, "~")) > 2 Then

? ? ? ? ? ? ? ?getstockbasicdatafun = .responsetext

? ? ? ? ? ?Else

? ? ? ? ? ? ? ?getstockbasicdatafun = .responsetext

? ? ? ? ? ?End If

? ? ? ? End With

? ? Else

? ? ? ? getstockbasicdatafun = "none"

? ? End If

End Function

Sub 獲取并顯示股票數(shù)據(jù)(ByVal scode As String)

On Error GoTo 錯誤清空

'-------------------------------處理代碼

If Left(scode, 1) = 6 Then

? ? scode = "sh" & scode

Else

? ? scode = "sz" & scode

End If

'-------------------------------獲取股票數(shù)據(jù)

Dim code_data As String

code_data = getstockbasicdatafun(scode)

If code_data = "none" Then

? ? MsgBox "未找到該股票"

? ? '-------------------------------清空數(shù)據(jù)

? ? Me.股票代碼 = ""

? ? Me.名稱 = ""

? ? Me.當(dāng)前價 = ""

? ? Me.漲跌 = ""

? ? Me.當(dāng)前漲幅 = ""

? ? Me.開盤價 = ""

? ? Me.最高價 = ""

? ? Me.最低價 = ""

? ? Exit Sub

End If


'-------------------------------分割處理顯示數(shù)據(jù)

Dim stockitem_array1

stockitem_array1 = Split(code_data, "~")

Me.股票代碼 = stockitem_array1(2)

Me.名稱 = stockitem_array1(1)

Me.當(dāng)前價 = stockitem_array1(3)

Me.開盤價 = stockitem_array1(5)

Me.最高價 = stockitem_array1(41)

Me.最低價 = stockitem_array1(42)

Me.漲跌 = Round(stockitem_array1(3) - stockitem_array1(5), 2)

Me.當(dāng)前漲幅 = stockitem_array1(32)

If Me.當(dāng)前漲幅 >= 0 Then

Me.當(dāng)前漲幅.ForeColor = RGB(255, 50, 50)

Else

Me.當(dāng)前漲幅.ForeColor = RGB(50, 255, 50)

End If

Exit Sub

錯誤清空:

? ? Me.股票代碼 = ""

? ? Me.名稱 = ""

? ? Me.當(dāng)前價 = ""

? ? Me.漲跌 = ""

? ? Me.當(dāng)前漲幅 = ""

? ? Me.開盤價 = ""

? ? Me.最高價 = ""

? ? Me.最低價 = ""

End Sub

Private Sub Form_Timer()

If Me.股票代碼 <> "" Then

Call 獲取并顯示股票數(shù)據(jù)(Me.股票代碼)

End If

End Sub


獲取股票實(shí)時行情數(shù)據(jù) Access數(shù)據(jù)庫系統(tǒng)功能講解VBA代碼編程實(shí)例的評論 (共 條)

分享到微博請遵守國家法律
师宗县| 昆山市| 于田县| 恩施市| 寿宁县| 鄂温| 扎赉特旗| 黑山县| 中方县| 芷江| 建德市| 赤峰市| 嘉兴市| 虞城县| 涪陵区| 定西市| 子洲县| 马龙县| 大田县| 邵东县| 漳浦县| 淮滨县| 宝应县| 竹北市| 进贤县| 乌苏市| 浮梁县| 高密市| 疏勒县| 北安市| 叙永县| 三河市| 彭泽县| 大渡口区| 固镇县| 会东县| 大石桥市| 綦江县| 长武县| 海淀区| 宁安市|