我在Excel(Mac)中首次尝试用户定义的功能并不顺利。这给了"函数或子未定义":
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('group_user', function(Blueprint $table)
{
$table->integer('user_id')->unsigned();
$table->integer('group_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('group_id')->references('id')->on('groups');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('group_user');
}}
奇怪的是,Function CylArea(d0 As Double, theta As Double, y As Double) As Double
CylArea = Pi() * (d0 ^ 2 / 4 + d0 * Tan(Radians(theta)) * y + Tan(Radians(theta)) ^ 2 * y ^ 2)
End Function
Function CylVolume(d0 As Double, theta As Double, y As Double) As Double
CylVolume = Pi() * (d0 ^ 2 / 4 * y + 1 / 2 * d0 * Tan(Radians(theta)) * y ^ 2 + 1 / 3 * Tan(Radians(theta)) ^ 2 * y ^ 3)
End Function
Function CylAreaDeriv(d0 As Double, theta As Double, y As Double) As Double
CylAreaDeriv = Pi() * (d0 * Tan(Radians(theta)) + 2 * Tan(Radians(theta)) ^ 2 * y)
End Function
中的Pi
会突出显示。
答案 0 :(得分:1)
您似乎正在尝试使用Excel函数,就像在VBA代码中的工作表中一样。这可能行不通。
尝试将Pi()
的所有实例更改为WorksheetFunction.Pi
,将Tan
的所有实例更改为Math.Tan
,将Radians
的所有实例更改为WorksheetFunction.Radians
,以便代码看起来更像是这样:
Function CylVolume(d0 As Double, theta As Double, y As Double) As Double
CylVolume = WorksheetFunction.Pi * (d0 ^ 2 / 4 * y + 1 / 2 * d0 * Math.Tan(WorksheetFunction.Radians(theta)) * y ^ 2 + 1 / 3 * Math.Tan(WorksheetFunction.Radians(theta)) ^ 2 * y ^ 3)
End Function