无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

歡迎光臨散文網(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í)例的評論 (共 條)

分享到微博請遵守國家法律
齐齐哈尔市| 柳林县| 连城县| 凤山县| 柯坪县| 江山市| 西乌珠穆沁旗| 肇源县| 津南区| 蓝田县| 陆良县| 台州市| 望奎县| 庆安县| 五寨县| 阜南县| 唐河县| 建宁县| 开原市| 长沙县| 保德县| 景东| 万州区| 穆棱市| 渭南市| 繁昌县| 玉溪市| 怀化市| 泗水县| 峡江县| 漠河县| 水富县| 许昌县| 横峰县| 肃北| 嵊泗县| 仁布县| 通许县| 磴口县| 金坛市| 翁源县|