我在一个新的vs项目中添加了两个vb文件,我似乎遇到了下面代码的最后一行的问题。我收到一个错误:没有为类型'Char'和'String'定义运算符'*'。
我对vb了解不多,所以有人可以向我解释最后一行中的内容以及我如何修复错误吗? mStream是一个FileStream
Public Shared Function GetCharImage(Font As Integer, c As Char) As Bitmap
If UnicodeFonts.mStream Is Nothing Then
UnicodeFonts.Init()
End If
' The following expression was wrapped in a checked-statement
UnicodeFonts.mStream = UnicodeFonts.Stream(Font - 1)
UnicodeFonts.mReader = UnicodeFonts.Reader(Font - 1)
' The following expression was wrapped in a checked-expression
UnicodeFonts.mStream.Seek(CLng(c * ""), 0)
编辑***
调用上述方法的行是这样的:
array(i - 1)= UnicodeFonts.GetCharImage(Font,CharType.FromString(Strings.Mid(Text,i)))
来自以下方法:
Public Shared Function GetStringImage(Font As Integer, Text As String) As Bitmap
' The following expression was wrapped in a checked-statement
Dim array As Bitmap() = New Bitmap(Strings.Len(Text) - 1 + 1 - 1) {}
Dim arg_19_0 As Integer = 1
Dim num As Integer = Strings.Len(Text)
Dim num2 As Integer
Dim height As Integer
For i As Integer = arg_19_0 To num
array(i - 1) = UnicodeFonts.GetCharImage(Font, CharType.FromString(Strings.Mid(Text, i)))
num2 += array(i - 1).Width
If array(i - 1).Height > height Then
height = array(i - 1).Height
End If
Next
Dim bitmap As Bitmap = New Bitmap(num2, height, PixelFormat.Format32bppArgb)
Dim graphics As Graphics = Graphics.FromImage(bitmap)
Dim arg_8C_0 As Integer = 1
Dim num3 As Integer = Strings.Len(Text)
For j As Integer = arg_8C_0 To num3
Dim num4 As Integer
graphics.DrawImage(array(j - 1), num4, 0)
num4 += array(j - 1).Width
Next
Dim arg_C4_0 As Integer = 1
Dim num5 As Integer = Strings.Len(Text)
For k As Integer = arg_C4_0 To num5
array(k - 1).Dispose()
Next
graphics.Dispose()
Return bitmap
End Function
代码正在处理包含字体的文件。
答案 0 :(得分:2)
我最好的猜测是,您正在尝试根据字符代码在文件中的特定偏移量处查找字体字符的数据。
您可以尝试以下方式:
UnicodeFonts.mStream.Seek(CLng(c) * 4), 0)
我在这里选择了4,假设你正在寻找的是4字节整数的表。
此处的更改是我首先使用CLng(c)
将c转换为数字,然后将其乘以另一个数字而不是字符串。
答案 1 :(得分:1)
问题在于您尝试将字符和字符串相乘:c * ""
字符和字符串不是数字,因此它们不能相乘。