Asp.Net教程,WinForm教程,Asp.Net MVC,vs2008教程,vs2010教程,Silverlight技术,源码下载,Asp.Net视频教程
全站热门标签
vs2010 Silverlight 存储过程 水晶报表 ADO.NET JavaScript LINQ AjaxPro DataGridView 面向对象 Extjs GridView XML DevExpress HTML教程 Oracle jQuery 分页 GDI+ Visual C++2010 MySQL Office2010 WPF MVC Dojo WCF4.0 VB.NET Sql2005 textbox cookie WCF WinForm Discuz!NT SQL经典语句 T-SQL checkbox ASPxGridView F# asp.net SQL VS2008新特性 DropDownList Access TreeView Ajax VS2008 页面执行时间 Flex 字符串 回调 VB2005 DataSet C#时间 ASP.NET性能优化 用户在线检测 动画
Framework C#技术VB.NET VC.NET WCF WPF
当前位置: 主页 > WinForm教程 > VB.NET >

VB2005代码与通达信数据格式

时间:2010-04-20 19:39来源:未知 作者:admin 点击:

基本声明
    Public NumBase(5) As Long '通达信格式基数
    Public NumUnit(4) As Long '每单位对应的16进制数
    Public NumUnitPrice(4) As Long '每单位对于的10进制数,已被从元为单位扩大1000倍


 基本模块
 

    Public Sub intTDXelg()
        NumBase(
0= 1065353216 : NumBase(1= 1082130432 : NumBase(2= 1090519040 : NumBase(3= 1098907648 : NumBase(4= 1109655552 ': NumBase(5) = 1118830592
        NumUnit(0= 4194304 : NumUnit(1= 2097152 : NumUnit(2= 1048576 : NumUnit(3= 524288 ': NumUnit(4) = 262144
        NumUnitPrice(0= 0 : NumUnitPrice(1= 4000 : NumUnitPrice(2= 8000 : NumUnitPrice(3= 16000 ': NumUnitPrice(4) = 32000
    End Sub

在form load 事件中调用intTDXelg

    Public Structure stockDayRecord '保存一门股票的日数据信息
        Dim stockdate As Date
        
Dim openor As Single
        
Dim hightor As Single
        
Dim lowor As Single
        
Dim endor As Single
        
Dim changor As Integer
        
Dim id As Integer
        
Dim VbP As Integer
    
End Structure

 

    Public Function getRealPrice(ByVal formerPrice As LongAs Long  '注意移植此函数是要把公共变量NumBase预NumUnit移动移植
        Dim i As Integer
        
For i = 1 To 4                                 '该函数可返回32元人民币以下对于的准确价格
            If formerPrice < NumBase(i) Then
                getRealPrice 
= (Val((formerPrice - NumBase(i - 1)) & "000"/ NumUnit(i - 1)) + NumUnitPrice(i - 1)
                
Exit For                                  ' & 000 相当于 * 1000,以‰为单位
            End If
        
Next i
    
End Function


读取模块
 

Function LoadDayData(ByVal filename As StringByRef dr() As stockDayRecord, ByVal t As ShortAs Long
 '股票读取接口,第一个参数为装载股票数据的结构体
        Dim fs As FileStream = File.OpenRead(filename)
        
Dim br As New BinaryReader(fs)
        
Dim n As Integer
        
Dim i As Integer, j As Integer
        
Select Case t
            
Case 1 '中天
              Case 2 '通达信 暂时不用
                n = (fs.Length - 4/ 32
                LoadDayData 
= n
                
ReDim dr(n)
                br.ReadInt32() 
'文件头到底是什么,另外是头天顺序颠放到了某个地方
                For i = 1 To n
                    
Dim d As Integer = br.ReadInt32()
                    dr(i).stockdate 
= DateSerial(d / 10000, (d Mod 10000/ 100, d Mod 100)
                    dr(i).openor 
= getRealPrice(br.ReadInt32) / 1000
                    dr(i).hightor 
= getRealPrice(br.ReadInt32) / 1000
                    dr(i).lowor 
= getRealPrice(br.ReadInt32) / 1000
                    dr(i).endor 
= getRealPrice(br.ReadInt32) / 1000
                    br.ReadInt32()
                    dr(i).changor 
= br.ReadInt32
                    dr(i).id 
= i
                    
If (dr(i).hightor <> dr(i).lowor) Then dr(i).VbP = dr(i).changor / ((dr(i).hightor - dr(i).lowor) * 1000)
                    br.ReadInt32()
                
Next
        
End Select
        fs.Dispose()
        LoadDayData 
= j
    
End Function



 

(责任编辑:admin)
Tags:VB2005
责任编辑:admin
返回顶部
------分隔线----------------------------
推荐内容
骆驼户外男 真皮磨砂日常休闲鞋 低帮 2011秋冬新款 专柜正品特价 骆驼户外男 真皮磨砂日常休闲鞋 低帮 2011秋冬新款 专柜正品特价