‘壹’ 用VB如何直接获取股票实时数据
可以通过调用ChinaStockWebService的服务来实现获取股票的实时数据,代码如下:
publicstring[]getStockInfo(stringstockcode)
{
//stringurl="http://hq.sinajs.cn/list="+stockcode;
//stockcode某只股票的代码
stringurl="http://hq.sinajs.cn/list=sh600683";
WebClientclient=newWebClient();
client.Headers.Add("Content-Type","text/html;charset=gb2312");
Streamdata=client.OpenRead(url);
StreamReaderreader=newStreamReader(data,Encoding.GetEncoding("gb2312"));
strings=reader.ReadToEnd();
reader.Close();
data.Close();
returns.Split(',');
}
‘贰’ 求vb高手 做一个软件实现股票自动买卖 我会通过另一个软件计算买卖时间和价格,用vb实现买卖过程
这个说复杂也容易,说容易也复杂。
容易就在于算法大家都知道,只要能实现查询,然后根据设计需要进行交易就是了。
复杂就在于凡属于金融领域的,不管是杀毒软件还是防火墙,都是重点监控种类。尤其是证券公司和银行,对于客户没有使用它们的终端而发生资金变动的话,那岂不是银行或证券公司的漏洞了?
要获得银行的访问权限,你看现在的银行主页,一输入密码就需要加载什么控件,那就是保护措施啊。然后证券公司的访问权限。当然,如果你的钱全部转到了证券公司,那只要证券公司的权限就可以了。
所以现在能够实现自动买卖的软件,都是证券公司自己写的程序。你现在应该知道其原因了。证券公司可不会随便让你查询它的档案的。
‘叁’ VB编程怎么编个能把一个网站的即时数据载入后按我的要求计算的程序,比如导入及时股票价格
不管你用什么编程语言,你都需要面对相同的问题:
1、导入网站数据需要网站给你提供XML服务、编程接口,这个需要问网站的管理员或者开发者;
2、如果第1条不适用,那么你需要分析网页的语法结构,通过规则性的字符串查找方法提取网站上的数据,这种方法就不怎么靠谱了!
‘肆’ VB如何读取股票大盘数据,20秒更新一次,并动态的显示到文本框中,请高手帮忙
这个要连接数据库的。。
‘伍’ 我想从网页上(比如网易、新浪)上实时抓取大盘和个股的实时行情,请给出VB的完整源码,并加注释。
下载遨游浏览器。打开你所需要的网页,比如新浪的大盘那里。然后点击浏览器的查看按钮,然后其中有个查看源代码。
就会弹出一个笔记本,然后就是你要的源代码。
也就是所谓的数据模式啦!我刚才一直想粘贴过来我刚刚得到的。可惜网络不让我发,不知道为什么。你自己试下就知道了。
‘陆’ VB 怎样调出股票板块信息
可以利用股票网页信息
‘柒’ VB 修改一个股票行情监测脚本 到了预定的股价就启动程序a.exe
Dim file1, file2 As String
Private Sub Command1_Click()
If Val(Text1.Text) > Val(Text2.Text) Then Shell (file1)
'text2.text为大于这个值时 执行
If Val(Text1.Text) < Val(Text3.Text) Then Shell (file2)
'text3.text为小于这个值时 执行
End Sub
Private Sub Command2_Click()
WebBrowser1.Navigate "http://.hexun.com/stock/q.php?code=" & Text4.Text
End Sub
Private Sub Command3_Click()
CommonDialog1.DialogTitle = "选择路径"
CommonDialog1.ShowOpen
file1 = CommonDialog1.FileName
End Sub
Private Sub Command4_Click()
CommonDialog1.DialogTitle = "选择路径"
CommonDialog1.ShowOpen
file2 = CommonDialog1.FileName
End Sub
Private Sub Form_Load()
Timer1.Interval = 6000
End Sub
Private Sub Timer1_Timer()
WebBrowser1.Refresh
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If Not (pDisp Is WebBrowser1.object) Then Exit Sub
Dim wenben As String
Dim a() As String
wenben = Me.WebBrowser1.Document.Body.innerText
a = Split(wenben, vbCrLf)
Text1.Text = wenben
For i = 0 To UBound(a)
If InStr(a(i), "代码:") > 0 And InStr(a(i), ".s") > 0 Then
Text1.Text = Right(a(i), (Len(a(i)) - InStr(a(i), ".s")) - 2)
Text5.Text = Mid(a(i), InStr(a(i), ".s") + 1, 2)
Exit For
End If
Next i
End Sub
‘捌’ 用VB 读取通达信实时股票数据(现价,涨幅)
关键是接口
我估计现在没有免费的接口了!!!
所以你想自己编程获取实时数据,几乎不可能了!!!
总之,没有有效的网络实时数据支持,这是开源股软的最致命的地方!!!
‘玖’ vb监视程序代码
窗体代码: Option Explicit Dim hChangeHandle As Long Dim hWatched As Long Dim terminateFlag As Long Private Sub Form_Load() lbMsg = "Press 'Begin Watch'" End Sub Private Sub cmdEnd_Click() If hWatched > 0 Then Call WatchDelete(hWatched) Unload Me Set Form1 = Nothing End Sub Private Sub cmdStop_Click() 'clean up by deleting the handle to the watched directory Call WatchDelete(hWatched) hWatched = 0 cmdBegin.Enabled = True lbMsg = "Press 'Begin Watch'" End Sub Private Sub cmdBegin_Click() Dim r As Long Dim watchPath As String Dim watchStatus As Long watchPath = "c:\bat" terminateFlag = False cmdBegin.Enabled = False lbMsg = "Using Explorer and Notepad, create, modify, rename, delete or " lbMsg = lbMsg & "change the attributes of a text file in the watched directory.""" 'get the first file text attributes to the listbox (if any) WatchChangeAction watchPath 'show a msgbox to indicate the watch is starting MsgBox "Beginning watching of folder " & watchPath & " .. press OK" 'create a watched directory hWatched = WatchCreate(watchPath, FILE_NOTIFY_FLAGS) 'poll the watched folder watchStatus = WatchDirectory(hWatched, 100) 'if WatchDirectory exited with watchStatus = 0, 'then there was a change in the folder. If watchStatus = 0 Then 'update the listbox for the first file found in the 'folder and indicate a change took place. WatchChangeAction watchPath MsgBox "The watched directory has been changed. Resuming watch..." '(perform actions) 'this is where you'd actually put code to perform a 'task based on the folder changing. 'FindNextChangeNotification API, again exiting if 'watchStatus indicates the terminate flag was set Do watchStatus = WatchResume(hWatched, 100) If watchStatus = -1 Then 'watchStatus must have exited with the terminate flag MsgBox "Watching has been terminated for " & watchPath Else: WatchChangeAction watchPath MsgBox "The watched directory has been changed again." '(perform actions) 'this is where you'd actually put code to perform a 'task based on the folder changing. End If Loop While watchStatus = 0 Else 'watchStatus must have exited with the terminate flag MsgBox "Watching has been terminated for " & watchPath End If End Sub Private Function WatchCreate(lpPathName As String, flags As Long) As Long 'FindFirstChangeNotification members: ' ' lpPathName: folder to watch ' bWatchSubtree: ' True = watch specified folder and its sub folders ' False = watch the specified folder only ' flags: OR'd combination of the FILE_NOTIFY_ flags to apply WatchCreate = FindFirstChangeNotification(lpPathName, False, flags) End Function Private Sub WatchDelete(hWatched As Long) Dim r As Long terminateFlag = True DoEvents r = FindCloseChangeNotification(hWatched) End Sub Private Function WatchDirectory(hWatched As Long, interval As Long) As Long 'Poll the watched folder. 'The Do..Loop will exit when: ' r = 0, indicating a change has occurred ' terminateFlag = True, set by the WatchDelete routine Dim r As Long Do r = WaitForSingleObject(hWatched, interval) DoEvents Loop While r <> 0 And terminateFlag = False WatchDirectory = r End Function Private Function WatchResume(hWatched As Long, interval) As Boolean Dim r As Long r = FindNextChangeNotification(hWatched) Do r = WaitForSingleObject(hWatched, interval) DoEvents Loop While r <> 0 And terminateFlag = False WatchResume = r End Function Private Sub WatchChangeAction(fPath As String) Dim fName As String List1.Clear fName = Dir(fPath & "\" & "*.*") If fName > "" Then List1.AddItem "path: " & vbTab & fPath List1.AddItem "file: " & vbTab & fName List1.AddItem "size: " & vbTab & FileLen(fPath & "\" & fName) List1.AddItem "attr: " & vbTab & GetAttr(fPath & "\" & fName) End If End Sub 模块代码: Option Explicit Public Const INFINITE = &HFFFF Public Const FILE_NOTIFY_CHANGE_FILE_NAME As Long = &H1 Public Const FILE_NOTIFY_CHANGE_DIR_NAME As Long = &H2 Public Const FILE_NOTIFY_CHANGE_ATTRIBUTES As Long = &H4 Public Const FILE_NOTIFY_CHANGE_SIZE As Long = &H8 Public Const FILE_NOTIFY_CHANGE_LAST_WRITE As Long = &H10 Public Const FILE_NOTIFY_CHANGE_LAST_ACCESS As Long = &H20 Public Const FILE_NOTIFY_CHANGE_CREATION As Long = &H40 Public Const FILE_NOTIFY_CHANGE_SECURITY As Long = &H100 Public Const FILE_NOTIFY_FLAGS = FILE_NOTIFY_CHANGE_ATTRIBUTES Or _ FILE_NOTIFY_CHANGE_FILE_NAME Or _ FILE_NOTIFY_CHANGE_LAST_WRITE Declare Function FindFirstChangeNotification Lib "kernel32" _ Alias "FindFirstChangeNotificationA" _ (ByVal lpPathName As String, _ ByVal bWatchSubtree As Long, _ ByVal dwNotifyFilter As Long) As Long Declare Function FindCloseChangeNotification Lib "kernel32" _ (ByVal hChangeHandle As Long) As Long Declare Function FindNextChangeNotification Lib "kernel32" _ (ByVal hChangeHandle As Long) As Long Declare Function WaitForSingleObject Lib "kernel32" _ (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long Public Const WAIT_OBJECT_0 = &H0 Public Const WAIT_ABANDONED = &H80 Public Const WAIT_IO_COMPLETION = &HC0 Public Const WAIT_TIMEOUT = &H102 Public Const STATUS_PENDING = &H103
‘拾’ 如何在VB6.0中根据设置的时间查询股票的数据,急急急。。。
不可以设置