Dim a As New Class1
        Dim b As New Class1
        a = CType(b, Class1)

解决方案 »

  1.   

    不好意思 ,我说错了
    不是对象,是A,B两个不同的类型值
    例如: Dim A as integer
    Dim B as string 
    1)我想通过获取A的类型来转换B的类型,不能手工改,而是要用程序,即先获取A类型,然后ctype B
      

  2.   

    不好意思 ,我说错了
    不是对象,是A,B两个不同的类型值
    例如: Dim A as integer
    Dim B as string 
    1)我想通过获取A的类型来转换B的类型,不能手工改,而是要用程序,即先获取A类型,然后ctype B
      

  3.   

    Dim A As Integer
            Dim B As String
            A = CInt(B)
      

  4.   

    Dim A As Integer
            Dim B As String
            Select Case A.GetType.ToString()
                Case "String"
                   
                    A = CStr(B)
                Case "Integer"
                    A = CInt(B)
            End Select
      

  5.   

    int a=1;
    string c="4";
    object b;
    b=Convert.ChangeType(c,a.GetType());
    Response.Write(b);
      

  6.   

    dim a as integer=1
    dim c as string 
    dim b as object
    b=Convert.ChangeType(c,a.GetType());
    Response.Write(b);
      

  7.   

    你把所有的类型判断一下 不就可以了吗CBool(expression)
    CByte(expression)
    CChar(expression)
    CDate(expression)
    CDbl(expression)
    CDec(expression)
    CInt(expression)
    CLng(expression)
    CObj(expression)
    CShort(expression)
    CSng(expression)
    CStr(expression)
      

  8.   


            Dim A As Integer
            Dim B As String
            Select Case A.GetTypeCode()
                Case "String"
                    A = CStr(B)
                Case "Integer"
                    A = CInt(B)
            End Select
      

  9.   

    b=Convert.ChangeType(c,a.GetType());