Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/302.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将c#代码转换为VB_C#_Vb.net - Fatal编程技术网

将c#代码转换为VB

将c#代码转换为VB,c#,vb.net,C#,Vb.net,我正在使用数学函数。代码如下。它是C代码。请使用CType(变量,类型)将其转换为VB。我试过了,但没有成功 iTmpWidth = (Integer)(Math.Floor((double)((double)GridCol.Width / (double)iTotalWidth * (double)iTotalWidth * ((double)e.Mar

我正在使用数学函数。代码如下。它是C代码。请使用CType(变量,类型)将其转换为VB。我试过了,但没有成功

 iTmpWidth = (Integer)(Math.Floor((double)((double)GridCol.Width /
                                   (double)iTotalWidth * (double)iTotalWidth *
                                   ((double)e.MarginBounds.Width / (double)iTotalWidth))))
请帮忙。

试试这个:

iTmpWidth = DirectCast(Math.Floor(CDbl(CDbl(GridCol.Width) 
    / CDbl(iTotalWidth) * CDbl(iTotalWidth) * (CDbl(e.MarginBounds.Width) 
    / CDbl(iTotalWidth)))), [Integer]);

很抱歉,堆栈溢出不是代码转换器。最好的对话方式是开始学习这两种语言,然后自己动手。请展示你的尝试。我只是试着打印gridview数据。上面的代码是以整数形式对齐marginError。错误更正为:将Integer更改为UInteger
CDbl
无法处理
null
,因此可能引发异常
无法强制转换
CDbl中没有错误,但在最后一个声明Integer中没有错误