| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 896 人关注过本帖
标题:求助 关于VB.net 类的调用问题
只看楼主 加入收藏
wingthau
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-9-24
收藏
 问题点数:0 回复次数:2 
求助 关于VB.net 类的调用问题
小弟在网上找到一个关于算文件CRC32 的一个类,

但不知道怎么在主窗体里调用这个类.

望各位大哥大姐帮忙....


Public Class CRC32
    Private Shared CRC32Table() As Integer
    Private Const BUFFER_SIZE As Integer = 1024

    Public Shared Function GetCRC32(ByVal file As String) As Integer
        Return GetCRC32(file, System.Text.Encoding.Default)
    End Function

    Public Shared Function GetCRC32(ByVal file As String, ByVal encoding As System.Text.Encoding) As Integer
        Dim sr As = New (file, encoding)
        Dim Result As Integer = GetCRC32(sr.BaseStream)
        sr.Close()
        Return Result
    End Function

    Public Shared Function GetCRC32(ByRef stream As ) As Integer
        Dim crc32Result As Integer
        crc32Result = &HFFFFFFFF

        Dim buffer(BUFFER_SIZE) As Byte
        Dim readSize As Integer = BUFFER_SIZE

        Dim count As Integer = stream.Read(buffer, 0, readSize)
        Dim i As Integer
        Dim iLookup As Integer
        Dim tot As Integer = 0

        Do While (count > 0)
            For i = 0 To count - 1
                iLookup = (crc32Result And &HFF) Xor buffer(i)
                crc32Result = ((crc32Result And &HFFFFFF00) \ &H100) And &HFFFFFF
                crc32Result = crc32Result Xor CRC32Table(iLookup)
            Next i
            count = stream.Read(buffer, 0, readSize)
        Loop

        Return Not (crc32Result)
    End Function

    Shared Sub New()
        Dim dwPolynomial As Integer = &HEDB88320
        Dim i As Integer, j As Integer

        ReDim CRC32Table(256)
        Dim dwCrc As Integer

        For i = 0 To 255
            dwCrc = i
            For j = 8 To 1 Step -1
                If (dwCrc And 1) Then
                    dwCrc = ((dwCrc And &HFFFFFFFE) \ 2&) And &H7FFFFFFF
                    dwCrc = dwCrc Xor dwPolynomial
                Else
                    dwCrc = ((dwCrc And &HFFFFFFFE) \ 2&) And &H7FFFFFFF
                End If
            Next j
            CRC32Table(i) = dwCrc
        Next i
    End Sub
End Class
搜索更多相关主题的帖子: file 大哥 网上 
2009-11-17 21:11
peteryhr
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2008-4-16
收藏
得分:0 
在主窗体里声明这个类的变量,并创建一个新实例。

dim myCRC32 as CRC32

myCRC32=new CRC32()

这样应该可以。

[ 本帖最后由 peteryhr 于 2010-1-14 10:05 编辑 ]
2010-01-14 10:03
liuyilin
Rank: 2
等 级:论坛游民
帖 子:26
专家分:40
注 册:2007-3-8
收藏
得分:0 
Shared直接调用
CRC32.GetCRC32()
2010-01-14 16:39
快速回复:求助 关于VB.net 类的调用问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.027949 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved