在VBA中键入不匹配

时间:2016-03-03 15:52:48

标签: vba autocad type-mismatch

我收到错误"输入不匹配"当我尝试在Autocad中运行此VBA代码时。第Theatts(TagNumber).TextString = BTextString行突出显示。

Public acad As Object
Public doc As Object
Public ms As Object
Public ss As Object
Public ssnew As Object
Public Theatts As Variant
Public MsgBoxResp As Integer

'declare global variables

Sub UpdateAttrib(TagNumber As Integer, BTextString As String)

  'This Sub Procedure tests the attribute data to check
  'that is not a null value

  If BTextString = "" Then
  'if the attribute is empty

    Theatts(TagNumber).TextString = ""
    'put a '-' place holder

   Else
   'if it is not empty

    Theatts(TagNumber).TextString = BTextString
    'use the attribute value

  End If

End Sub

Sub setupsv()
'name of function
UserForm1.show
'display the dialogue box
'UserForm1
End Sub

2 个答案:

答案 0 :(得分:1)

我修改了代码,不再遇到“类型不匹配”的问题。 显然,这是一个简单的程序,但我打算逐步建立它。

public class MainActivity extends AppCompatActivity{
int midx ;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    synchronized (this){
        doMenu(0);
        notify();
    }
}
public void doMenu(int midx) {
    synchronized (this) {
        while (midx >=0) {
            switch (midx) {
                case Constants.MENU_TYPE_SPLASH:
                    Intent m_sp = new Intent(MainActivity.this, Splash.class);
                    m_sp.putExtra("main_index_value", midx);
                    startActivityForResult(m_sp, Constants.REQUEST_RESULT_CODE);
                    break;
                case Constants.MENU_TYPE_MAIN:
                    Intent m_mm = new Intent(MainActivity.this, MainMenu.class);
                    m_mm.putExtra("main_index_value", midx);
                    startActivityForResult(m_mm, Constants.REQUEST_RESULT_CODE);
                    break;
            }
        }
        try {
            wait();
        }catch(InterruptedException e){
            e.printStackTrace();
        }
    }
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
                                Intent data) {
    if (resultCode == Constants.REQUEST_RESULT_CODE) {
        synchronized (this) {
            midx = data.getIntExtra("index_value", 0);
        }
        notify();
        }
}
}

答案 1 :(得分:0)

Theatts不是String的数组,而是Variant。 使用Redim对其进行初始化或将其声明为String数组(或Variant数组,如果你坚持的话)。