我在VB下定义了如下两个函数,现在我转到DELPHI编程,想用VB现成自定义的函数。之前直接翻译成DELPHI代码总出错(刚学DELPHI),请教哪位大虾,告诉我如何将这两个函数封装成DLL,之后在DELPHI里直接调用,步骤尽可能详细些。
我尝试过自己封装,结果在DELPHI下提示“未找到程序接入点”之类的错误。Private Function IsDelimiter(ByVal Char As Byte) As Boolean
Dim S As String
S = Chr(Char)
IsDelimiter = False
If S = " " Or S = "," Or S = "." Or S = "?" Or S = vbCr Or S = vbLf Or S = "/" Or S = "\" Or S = "(" Or S = ")" Or S = "[" Or S = "]" Or S = "*" Then
IsDelimiter = True
End If
End Function
Private Function GetWord(ts As String, pos As Long) As String
Dim bArr() As Byte, pos1 As Integer, pos2 As Integer, i As Integer
bArr = StrConv(ts, vbFromUnicode)
pos1 = 0: pos2 = UBound(bArr)
For i = pos - 1 To 0 Step -1
If IsDelimiter(bArr(i)) Then
pos1 = i + 1
Exit For
End If
Next
For i = pos To UBound(bArr)
If IsDelimiter(bArr(i)) Then
pos2 = i - 1
Exit For
End If
Next
If pos2 > pos1 Then
ReDim bArr2(pos2 - pos1) As Byte
For i = pos1 To pos2
bArr2(i - pos1) = bArr(i)
Next
GetWord = StrConv(bArr2, vbUnicode)
Else
GetWord = ""
End If
End Function
我尝试过自己封装,结果在DELPHI下提示“未找到程序接入点”之类的错误。Private Function IsDelimiter(ByVal Char As Byte) As Boolean
Dim S As String
S = Chr(Char)
IsDelimiter = False
If S = " " Or S = "," Or S = "." Or S = "?" Or S = vbCr Or S = vbLf Or S = "/" Or S = "\" Or S = "(" Or S = ")" Or S = "[" Or S = "]" Or S = "*" Then
IsDelimiter = True
End If
End Function
Private Function GetWord(ts As String, pos As Long) As String
Dim bArr() As Byte, pos1 As Integer, pos2 As Integer, i As Integer
bArr = StrConv(ts, vbFromUnicode)
pos1 = 0: pos2 = UBound(bArr)
For i = pos - 1 To 0 Step -1
If IsDelimiter(bArr(i)) Then
pos1 = i + 1
Exit For
End If
Next
For i = pos To UBound(bArr)
If IsDelimiter(bArr(i)) Then
pos2 = i - 1
Exit For
End If
Next
If pos2 > pos1 Then
ReDim bArr2(pos2 - pos1) As Byte
For i = pos1 To pos2
bArr2(i - pos1) = bArr(i)
Next
GetWord = StrConv(bArr2, vbUnicode)
Else
GetWord = ""
End If
End Function
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货