| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 434 人关注过本帖
标题:VB6与VB2005
只看楼主 加入收藏
didiguo
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2006-7-29
收藏
 问题点数:0 回复次数:0 
VB6与VB2005

引用http://www.microsoft.com/china/msdn/library/langtool/vbnet/dnvs05VBBestPrac.mspx?mfr=true中的方法,我编写了一个对字符串产生哈希码的程序,如下:
Imports System
Imports System.Security.Cryptography
Imports System.Text
Imports System.IO
<ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _
Public Class ComClass1
#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "948fc546-09c2-4c0d-98f8-7f410304179b"
Public Const InterfaceId As String = "218b767e-03fa-4244-b0a6-71d94fb30b44"
Public Const EventsId As String = "dee9968a-7a7f-436a-968e-dc6d713e2138"
#End Region
' A creatable COM class must have a Public Sub New()
' with no parameters, otherwise, the class will not be
' registered in the COM registry and cannot be created
' via CreateObject.
Public Sub New()
MyBase.New()
End Sub
Dim inputstr As String
Public Function input(ByVal xx As String)
inputstr = ""
inputstr = xx
End Function
Public Function output() As String
'Dim g As Guid = Guid.NewGuid()
'Return g.ToString()
Dim HashValue() As Byte
Dim str
Dim MessageString As String = inputstr
'Create a new instance of the UnicodeEncoding class to
'convert the string into an array of Unicode bytes.
Dim UE As New UnicodeEncoding()
'Convert the string into an array of bytes.
Dim MessageBytes As Byte() = UE.GetBytes(MessageString)
'Create a new instance of the SHA1Managed class to create
'the hash value.
Dim SHhash As New SHA1Managed()
'Create the hash value from the array of bytes.
HashValue = SHhash.ComputeHash(MessageBytes)
'Display the hash value to the console.
Dim b As Byte
str = ""
str = str & Chr(13) & Chr(10)
For Each b In HashValue
str = str & b
Next b
Return str
End Function
Public Function ReturnDecimal() As Decimal
Return 1.1
End Function
End Class


然后,用VB6进行引用,如下:
Private Sub Command1_Click()
Dim a As ClassLibrary2.ComClass1
Set a = New ClassLibrary2.ComClass1
Dim b
a.input (Text2.Text)
b = a.output
Text1.Text = CStr(b)
End Sub


运行一切正常,但是VB6生成的EXE文件在其他机器上运行却报错:
《运行时错误“429” ActiveX部件不能创建对象》
我就安装了.NET FRAMEWORK 2.0,依然不行,您能否给以帮助解答,谢谢

2006-07-29 15:16
快速回复:VB6与VB2005
数据加载中...
 
   



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

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