我需要访问模块(而不是类)中的公共功能。这是我尝试过的:
CREATE Function udf_ExtractNumber (@String varchar(256))
RETURNS VARCHAR(256)
AS
BEGIN
DECLARE @AlphaNumeric varchar(256)
,@Res varchar(256)
SET @AlphaNumeric = @String
SET @Res = NULL
WHILE (PATINDEX('%[0-9]%', @AlphaNumeric) > 0 )
BEGIN
IF (PATINDEX('%[0-9]%', @AlphaNumeric) >0 AND PATINDEX('%[0-9]%', @AlphaNumeric) < CHARINDEX('.', @AlphaNumeric))
BEGIN
SET @Res = CONCAT(@Res ,SUBSTRING(@AlphaNumeric, PATINDEX('%[0-9]%', @AlphaNumeric), 1) )
SET @AlphaNumeric = RIGHT(@AlphaNumeric,len(@AlphaNumeric)- PATINDEX('%[0-9]%', @AlphaNumeric))
END
ELSE IF (CHARINDEX('.', @AlphaNumeric) >0 AND CHARINDEX('.', @AlphaNumeric) < PATINDEX('%[0-9]%', @AlphaNumeric))
BEGIN
SET @Res = CONCAT(@Res ,SUBSTRING(@AlphaNumeric, CHARINDEX('.', @AlphaNumeric), 1) )
SET @AlphaNumeric = RIGHT(@AlphaNumeric,len(@AlphaNumeric)- CHARINDEX('.', @AlphaNumeric))
END
ELSE IF (PATINDEX('%[0-9]%', @AlphaNumeric) >0)
BEGIN
SET @Res = CONCAT(@Res, SUBSTRING(@AlphaNumeric, PATINDEX('%[0-9]%', @AlphaNumeric), 1) )
SET @AlphaNumeric = RIGHT(@AlphaNumeric,len(@AlphaNumeric)- PATINDEX('%[0-9]%', @AlphaNumeric))
END
ELSE IF (CHARINDEX('.', @AlphaNumeric) >0 )
BEGIN
SET @Res = CONCAT(@Res,SUBSTRING(@AlphaNumeric, CHARINDEX('.', @AlphaNumeric), 1))
SET @AlphaNumeric = RIGHT(@AlphaNumeric,len(@AlphaNumeric)- CHARINDEX('.', @AlphaNumeric))
END
END
Return @Res
END
但是,这甚至不涉及模块本身,我只是获得可执行文件的名称。
答案 0 :(得分:0)
VB.NET中的模块只不过是静态类。您无需创建静态类的实例,只需在声明模块的范围内的任何位置调用其成员。
public class DemoActivity extends AppCompatActivity implements View.OnClickListener{
Button mBtnAutomaticClick;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_report_bug);
mBtnAutomaticClick = findViewById(R.id.automatic_click_demo);
mBtnAutomaticClick.setOnClickListener(this);
mBtnAutomaticClick.performClick(); // for automatic click event
}
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.automatic_click_demo:
// your code
break;
}
}
答案 1 :(得分:0)
正如@jmcilhinney在评论中所说,使用反射时,模块就像类。您可以使用GetType
或GetTypes
方法访问它。
Dim asm As Assembly = Assembly.GetExecutingAssembly
Dim my_module = asm.GetType("Module_Full_Name")
Dim allMethods = my_module.GetMethods()