| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 7181 人关注过本帖, 6 人收藏
标题:[转载]Visual Basic COM 讲座
取消只看楼主 加入收藏
ioriliao
Rank: 7Rank: 7Rank: 7
来 自:广东
等 级:贵宾
威 望:32
帖 子:2829
专家分:647
注 册:2006-11-30
收藏
得分:0 
QegoFdIg.rar (7.5 KB) [转载]Visual Basic COM 讲座


自己写的程序示例,没毛的狗

/images/2011/147787/2011051411021524.jpg" border="0" />
2007-04-15 23:00
ioriliao
Rank: 7Rank: 7Rank: 7
来 自:广东
等 级:贵宾
威 望:32
帖 子:2829
专家分:647
注 册:2006-11-30
收藏
得分:0 
以下是引用Joforn在2007-4-15 18:49:12的发言:
会的人不会看,不会的看不懂。

老兄此语差矣...
难道会看的人他之所以会看...是凭空而来的么...
之所以不会才看...
不会的沿尚若看都不看又何来懂!


/images/2011/147787/2011051411021524.jpg" border="0" />
2007-04-16 14:00
ioriliao
Rank: 7Rank: 7Rank: 7
来 自:广东
等 级:贵宾
威 望:32
帖 子:2829
专家分:647
注 册:2006-11-30
收藏
得分:0 

封装存取文本文件的一个例子
Private FileName_ As String '文件名
Private FileNumber_ As Variant '文件编号
Public Enum IOType
ForInput = 1
ForOutPut = 2
ForBinary = 3
End Enum
Private OpenType_ As IOType
Private OutPutText_ As Variant

Property Get OpenType() As IOType '读取打开类型属性
OpenType = OpenType_
End Property

Property Let OpenType(NewValue As IOType) '设置打开类型属性
OpenType_ = NewValue
End Property

Property Get FileName() As String '读取文件路径属性

FileName = FileName_
End Property

Property Let FileName(NewFileName As String) '读取文件路径属性
FileName_ = NewFileName
End Property

Property Get FileNumber() As Variant '读取文件编号属性
FileNumber = FileNumber_
End Property
Property Let FileNumber(NewFileNumber As Variant) '设置文件编号属性
FileNumber_ = NewFileNumber
End Property
Property Get OutPutText() As Variant '设置写入文件内容
OutPutText = OutPutText_
End Property
Property Let OutPutText(NewText As Variant) '读取写入文件内容
OutPutText_ = NewText
End Property
Public Function Enter() As Variant '方法
If OpenType = ForInput Then
Enter = For_Input
ElseIf OpenType = ForOutPut Then
For_Oput
' Else
End If
End Function

Private Function For_Input() As Variant '读取文件
Dim Str As Variant

Open FileName_ For Input As #FileNumber
While Not EOF(1)
Line Input #1, Str
For_Input = For_Input + Str + vbCrLf
Wend

Close #FileNumber
End Function


Private Function For_Oput() '写入文件

Open FileName_ For Output As #FileNumber
Print #FileNumber, OutPutText_
Close #FileNumber
End Function


/images/2011/147787/2011051411021524.jpg" border="0" />
2007-04-22 22:39
ioriliao
Rank: 7Rank: 7Rank: 7
来 自:广东
等 级:贵宾
威 望:32
帖 子:2829
专家分:647
注 册:2006-11-30
收藏
得分:0 
呵呵...总算有一个人会欣赏的...hyhhd兄...可否加Q交流交流!82530662

/images/2011/147787/2011051411021524.jpg" border="0" />
2007-04-23 22:09
ioriliao
Rank: 7Rank: 7Rank: 7
来 自:广东
等 级:贵宾
威 望:32
帖 子:2829
专家分:647
注 册:2006-11-30
收藏
得分:0 

模拟vb.net string类:


Private Text_ As String
Public Enum Str_Conv '字格式转换常数
FirstByteToUpper = 3 '3 第一个英文字大写
HalfToAll = 4 '4 所有半型字转全型字
AllToHalf = 8 '8 所有全型字转半型字
SingleCodeToUnicode = 64 '64 所有Single Code字转成UniCode字
UniCodeToSingleCode = 128 '128 所有UniCode字转成Single Code字
End Enum

Property Get Text() As String
Text = Text_
End Property

Property Let Text(ByVal NewText As String)
Text_ = NewText
End Property


Public Function GetLeft(ByVal LeftIndex As Integer) As String '截取字串左边某几个字符
GetLeft = Left(Text_, LeftIndex)
End Function

Public Function GetRight(ByVal RightIndex As Integer) As String '截取字串右边某几个字符
GetRight = Right(Text_, RightIndex)
End Function

Public Function GetMid(ByVal MidIndex As Integer, ByVal LenIndex As Integer) As String '截取字串右边某几个字符
GetMid = Mid(Text_, MidIndex, LenIndex)
End Function


Public Function ToLower() As String '字符串全转小写
ToLower = LCase(Text_)
End Function
Public Function ToUpper() As String '字符串全转大写
ToUpper = UCase(Text_)
End Function
Public Function SetStrConv(ByVal TextConv As Str_Conv) As String '字格式转换
SetStrConv = StrConv(Text_, TextConv)
End Function

Public Function InStrIndex(ByVal SubText As String) As Integer '传回字串里某个字串在第几个字的位置
InStrIndex = InStr(Text_, SubText)
End Function

Public Function InStrBIndex(ByVal SubBText As String) As Integer '传回字串里某个字串在第几个字符的位置
InStrBIndex = InStrB(Text_, SubBText)
End Function

Public Function GetLen() As Integer '传回字串有多少字数
GetLen = Len(Text_)
End Function

Public Function GetLenB() As Integer '传回字串有多少字符
GetLenB = LenB(Text_)
End Function

Public Function InStrRevIndex(ByVal InstrRevText As String, ByVal StartFindIndex As Integer) As String 'InStrRev是从起始位置开始倒着找
InStrRevIndex = InStrRev(InstrRevText, StartFindIndex)
End Function

Public Function ToLTrim() As String '删除字串左边的空白字串
ToLTrim = LTrim(Text_)
End Function

Public Function ToRTrim() As String 'RTrim 删除字串右边的空白字串
ToRTrim = RTrim(Text_)
End Function

Public Function ToTrim() As String 'Trim 删除字串首尾的空白字串
ToTrim = Trim(Text_)
End Function

Public Function SetReplace(ByVal WillFindString As String, ByVal WillReplaceString As String, ByVal StartIndex As Integer, ByVal GroundIndex As Integer) As String
SetReplace = Replace(Text_, WillFindString, WillReplaceString, StartIndex, GroundIndex)
End Function '取代自串中某些字符串

Public Function LetStrReverse() As String '反转字符串
LetStrReverse = StrReverse(Text_)
End Function


/images/2011/147787/2011051411021524.jpg" border="0" />
2007-04-24 18:56
ioriliao
Rank: 7Rank: 7Rank: 7
来 自:广东
等 级:贵宾
威 望:32
帖 子:2829
专家分:647
注 册:2006-11-30
收藏
得分:0 
源代码:
H5hkLkU5.rar (9.61 KB) [转载]Visual Basic COM 讲座



/images/2011/147787/2011051411021524.jpg" border="0" />
2007-04-24 18:59
ioriliao
Rank: 7Rank: 7Rank: 7
来 自:广东
等 级:贵宾
威 望:32
帖 子:2829
专家分:647
注 册:2006-11-30
收藏
得分:0 
这还要怎么样的注释

/images/2011/147787/2011051411021524.jpg" border="0" />
2007-04-24 22:08
快速回复:[转载]Visual Basic COM 讲座
数据加载中...
 
   



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

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