我有这个代码。并且此代码适用于单击按钮。
这是代码。
X1picG00 = Double.Parse(XstrG00) * DrawScale
Y1picG00 = PictureBox1.Height - Double.Parse(YstrG00) * DrawScale
X2picG00 = Double.Parse(XendG00) * DrawScale
Y2picG00 = PictureBox1.Height - Double.Parse(YendG00) * DrawScale
X1picG00 = X1picG00 * Math.Cos(theta) - Y1picG00 * Math.Sin(theta)
Y1picG00 = X1picG00 * Math.Sin(theta) + Y1picG00 * Math.Cos(theta)
X2picG00 = X2picG00 * Math.Cos(theta) - Y2picG00 * Math.Sin(theta)
Y2picG00 = X2picG00 * Math.Sin(theta) + Y2picG00 * Math.Cos(theta)
PictureBox1.CreateGraphics().DrawLine(Pens.White, Int(X2picG00 + PicBorderX), Int(Y2picG00 + PicBorderY), Int(X1picG00 + PicBorderX), Int(Y1picG00 + PicBorderY))
当程序到达此代码时。
PictureBox1.CreateGraphics().DrawLine(Pens.White, Int(X2picG00 + PicBorderX), Int(Y2picG00 + PicBorderY), Int(X1picG00 + PicBorderX), Int(Y1picG00 + PicBorderY))
它告诉我这个错误。
An unhandled exception of type 'System.Reflection.AmbiguousMatchException' occurred in Microsoft.VisualBasic.dll
Additional information: Overload resolution failed because no Public 'DrawLine' can be called without a narrowing conversion:
'Public Sub DrawLine(pen As System.Drawing.Pen, x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer)':
Argument matching parameter 'x1' narrows from 'Double' to 'Integer'.
Argument matching parameter 'y1' narrows from 'Double' to 'Integer'.
Argument matching parameter 'x2' narrows from 'Double' to 'Integer'.
Argument matching parameter 'y2' narrows from 'Double' to 'Integer'.
'Public Sub DrawLine(pen As System.Drawing.Pen, x1 As Single, y1 As Single, x2 As Single, y2 As Single)':
Argument matching parameter 'x1' narrows from 'Double' to 'Single'.
Argument matching parameter 'y1' narrows from 'Double' to 'Single'.
Argument matching parameter 'x2' narrows from 'Double' to 'Single'.
Argument matching parameter 'y2' narrows from 'Double' to 'Single'.
我不明白为什么会发生这个错误以及它是什么。
这是什么错误,我该如何解决?
附加信息:变量 XstrG00
和 XendG00
以及 YstrG00
和 YendG00
有一个值。
以及它们的值取决于 TextBoxes
.
而 DrawScale
变量的值为 0.7
.
变量 PicBorderX
的值为 70
。
PicBorderY
变量的值为 10
.