运算符 * 未为类型 char 和 string 定义

Operator * Not Defined for types char and string

我在一个新的 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(字体, CharType.FromString(Strings.Mid(文本, 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

代码正在处理包含字体的文件。

问题是您正在尝试将一个字符和一个字符串相乘:c * ""字符和字符串不是数字,因此它们不能相乘。

我的最佳猜测是您正在尝试根据字符代码在文件中的特定偏移处查找字体字符的数据。

您可以尝试类似的方法:

UnicodeFonts.mStream.Seek(CLng(c) * 4), 0)

我在这里选择了 4,假设您要查找的是 table 4 字节整数。

这里的变化是我首先使用 CLng(c) 将 c 转换为数字,然后将其乘以另一个数字,而不是字符串。