我有一個項目,我已經從VB6轉換爲使用Visual Studio 2008 VB.NET。我有一行代碼拋出和運行時出錯,但不能編譯。在VB6中運行良好。代碼:從類型'字體'轉換爲類型'字符串'是無效的VB6到VB.NET
SizingLabel.Font = VB6.FontChangeName(SizingLabel.Font, FromObject.Font)
的錯誤是:
Conversion from type 'Font' to type 'String' is not valid.
我不知道爲什麼它被拋出InvalidCastException
我認爲字體是一個字符串。我嘗試添加.ToString()
的一切,但是當我這樣做,我在IDE中得到一個錯誤:
Value of type 'String' cannot be converted to 'System.Drawing.Font'.
可有人請點我在正確的方向?
使用FromObject.Font.FamilyName –