CapitolSoft Banner
Features
Tutorials
F.A.Q.s
Downloads
Articles
Open Architecture
Control Development Kit
RAD Foundation Class
Enhanced IntelliSense
Samples
Migration Center
Links
RadVC Migration Center

Programmed a lot in Visual Basic but a newbie to Visual C++? Find C++ a tough language? No fear. Help is just around the corner.

In this area, we will be be providing you with useful hints and tips to program in Microsoft Visual C++. We have designed this page with our Visual Basic programmers in mind, so every C / C++ 'thing' you will see here, will have a VB flavor with it.

We do need your ideas and feedback on this page. Please write to us if you feel some issues are missing or not addressed adequately.

 

 
Visual Basic C++ (MFC, RFC)
Variable Declarations
Dim x As Integer
Dim s As String
Dim s1, s2 As String
Dim o 'Implicitly Object
Dim obj As New Object()
Public name As String
int x;
CString s;
CString s1, s2;
Object o;
Object* pObj = new Object();

public: // defined in a class declaration
    CString name;
Statements
Response.Write("foo") Response.Write("foo");
Comments
' This is a comment

' This
' is
' a
' multi-line
' comment
// This is a comment

/*
This
is
a
multi-line
comment
*/
Accessing Indexed Properties
Dim s, value As String
s = Request.QueryString("Name")
value = Request.Cookies("Key").Value

'Note that default non-indexed properties
'must be explicitly named in VB
CString s = Request.QueryString["Name"];
CString value = Request.Cookies["key"];
Arrays
Dim a(3) As String
a(0) = "1"
a(1) = "2"
a(2) = "3"
CString a[3];
a[0] = "1";
a[1] = "2";
a[2] = "3";
Initialization
Dim s As String = "Hello World"
Dim i As Integer = 1
Dim a() As Double = { 3.00, 4.00, 5.00 }
CString s = "Hello World";
int i = 1;
double[] a = { 3.00, 4.00, 5.00 };
If Statements
If Not (Request.QueryString = Null)
...
End If
if (Request.QueryString != NULL)
{
...
}
Case Statements
Select (index)
case 1 :
...
case 2 :
...
case 3 :
...
End Select



switch (index)
{
    case 1:
        ...
        break;
    case 2:
        ...
        break;
    case 3:
        ...
        break;
    default:
        ...
        break;
}
For Loops
Dim I As Integer
For I = 0 To 2
    a(I) = "test"
Next
for (int i=0; i<3; i++)
    a(i) = "test";
While Loops
Dim I As Integer
I = 0
Do While I < 3
' Do something
I = I + 1
Loop
int i = 0;
while (i<3)
{
// Do Something
i += 1;
}
String Concatenation
Dim s1, s2 As String
s2 = "hello"
s2 &= " world"
s1 = s2 & " !!!"
CString s1;
CString s2 = "hello";
s2 += " world";
s1 = s2 + " !!!";
Event Handlers
Sub MyButton_Click()
...
End Sub
void MyButton_Click()
{
...
}
Casting
Dim bj As MyObject
obj = Session("Some Value")
MyObject* obj = (MyObject*)Session["Some Value"];
Conversion
Dim i As Integer
Dim s As String
Dim d As Double

i = 3
s = Str(i)
d = CDbl(s)
int i = 3;
CString s;

s.Format("%d", i);
double d = atol(s);

 

[ Home ][ Order Now ][Feedback][ Contact Us ][ About Capitolsoft ]
[ Features ][ Tutorial ][ Samples ][ F.A.Q.s ][ Download ][ CDK ]