我正在尝试在VB6中实现一个接口.我已经定义了Cast_Speed这样的类......
Public Function Run_Time() As Long
End Function
Run Code Online (Sandbox Code Playgroud)
和这样的实现......
Option Explicit
Implements Cast_Speed
Public Function Cast_Speed_Run_Time() As Long
Cast_Speed_Run_Time = 0
End Function
Run Code Online (Sandbox Code Playgroud)
但是试图编译它会让'对象模块需要为接口'Cast_Speed'实现'Run_Time'.谁能看到我做错了什么?我的子程序似乎很好,但我尝试的所有功能都有这个问题.
我在C#ASP.Net程序中有一个在回发期间填充的对象数组,我希望在下一个回发期间恢复它们.为此,我在Default类定义中包含了数组声明,因此保存了: -
this.Session["This"] = this;
Run Code Online (Sandbox Code Playgroud)
并恢复: -
Default saved_stuff = (Default) this.Session["This"];
Run Code Online (Sandbox Code Playgroud)
这适用于除以下之外的所有内容: -
MyClass [] my_array;
Run Code Online (Sandbox Code Playgroud)
恢复时,saved_stuff.my_array总是如此null.
MyClass定义如下: -
public MyClass : ISerializable
{
private string some_string;
private double some_double;
// some more simple members
// Some getters and setters
// ISerializable Implementation
}
Run Code Online (Sandbox Code Playgroud)
我尝试过制作MyClass工具,ISerializable但这没有任何区别.有谁知道我应该做什么?
编辑回答@ Michael的问题,我正在做的事情......
for (int i = 0; i <= saved_stuff.my_array.GetUpperBound(0); i++)
{
// blah blah
}
Run Code Online (Sandbox Code Playgroud)
失败的"对象引用未设置为对象的实例".在调试时,所有其他成员变量Default都可见saved_stuff.
我正在使用Enum类型,以防止使用虚假值:-
Public Class MyClass1
Public Enum MyEnum As Byte
FIRST
SECOND
End Enum
Private my_var As MyEnum
Public Property MyVar As MyEnum
Get
Return my_var
End Get
Set
my_var = Value
End Set
End Property
End Class
Public Sub MyWorks
Dim my_object As MyClass1 = New MyClass1
my_object.MyVar = 1 ' Compilation Error
my_object.MyVar = 33 ' Compilation Error
If my_object.MyVar = 1 Then ' No Compilation Error
End If
If my_object.MyVar = 27 Then ' No Compilation Error
End …Run Code Online (Sandbox Code Playgroud) 我试图创建都实现的基类和派生类ICloneable。在我看来,基类Clone方法应处理所有基类属性,而派生类Clone方法应处理所有派生类属性,并使用基类的Clone方法。结果是这样的:
Public Class MyBaseClass
Implements ICloneable
Private my_base_var As Integer
Public Function Clone() As Object Implements System.ICloneable.Clone
Dim new_base_class As MyBaseClass = New MyBaseClass
new_base_class.my_base_var = my_base_var
Return new_base_class
End Function
End Class
Public Class MySubClass
Inherits MyBaseClass
Implements ICloneable
Private my_sub_var As Integer
Public Overloads Function Clone() As Object Implements System.ICloneable.Clone
Dim new_sub_class As MySubClass = CType(MyBase.Clone, MySubClass) ' (1)
new_sub_class.my_sub_var = Me.my_sub_var
Return new_sub_class
End Function
End Class
Run Code Online (Sandbox Code Playgroud)
这导致在Unable …
我正在将一些VB6代码转换为VB.Net.由于我的VB6安装似乎损坏无法修复,我使用记事本阅读原始源代码,可以看到文件顶部附近: -
Attribute VB_Name = "clsBulge"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Description = "Some text here"
Attribute VB_Ext_KEY = "SavedWithClassBuilder" ,"Yes"
Attribute VB_Ext_KEY = "Member0" ,"collBulges"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Run Code Online (Sandbox Code Playgroud)
在作品中: -
Public Property Let Amplitude(ByVal vData As Double)
Attribute Amplitude.VB_Description = "Some text here"
mvaInternal = vData
End Property
Run Code Online (Sandbox Code Playgroud)
问题是,转换为VB.Net时,我是否要担心这个问题?如果是这样,我在哪里可以找出所有这些东西的含义?
我一直在使用工具 - >选项 - >字体和颜色在我的新Visual Studio 2017(社区)中摆弄各种C#项目的颜色.除了this关键字,一切都很好.
有没有人碰巧知道哪一个显示项可以改变颜色会影响this关键字?
我试图创建一个重载的一元 - 运算符,但无法获取编译代码.该代码的简化版本如下: -
class frag
{
public:
frag myfunc (frag oper1,
frag oper2);
frag myfunc2 (frag oper1,
frag oper2);
friend frag operator + (frag &oper1,
frag &oper2);
frag operator - ()
{
frag f;
f.element = -element;
return f;
}
private:
int element;
};
frag myfunc (frag oper1, frag oper2)
{
return oper1 + -oper2;
}
frag myfunc2 (frag oper1, frag oper2)
{
return oper1 + oper2;
}
frag operator+ (frag &oper1, frag &oper2)
{
frag innerfrag;
innerfrag.element = …Run Code Online (Sandbox Code Playgroud) 我有以下(削减)类定义,它有编译错误.
#include <iostream>
#include <string>
class number
{
public:
friend std::ostream &operator << (std::ostream &s, const number &num);
friend std::string &operator << (std::string, const number &num);
friend std::istream &operator >> (std::istream &s, number &num);
friend std::string &operator >> (std::string, number &num);
protected:
private:
void write ( std::ostream &output_target = std::cout) const;
void read ( std::istream &input_source = std::cin);
void to_string ( std::string &number_text) const;
void to_number (const std::string &number_text);
};
std::istream & operator >> (std::istream &s, number &num)
{
num.read …Run Code Online (Sandbox Code Playgroud) 我发现,当我更改窗体上几个控件的TabIndex属性时,一旦我转回原位,VB6会将它们重置为不同的值(不一定是旧值)。这变得很烦人。
有谁知道如何防止这种情况发生,或者如果无法阻止这种情况发生,则使用哪种方法选择值(以便我可以使用它而不是反对它)?
我将在C++中使用SQLite,所以我决定先学习它.但我的问题仍然是,SQL命令是非常像SQLite还是我应该在SQLite之前学习它?