English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I want to write a code in visual basic that dispalys on the screen even numbers between 2 and 10. I am new to Visual Basic. I need the code for this project. Can someone help me Please.

2007-01-10 15:18:24 · 4 answers · asked by stevenkk 1 in Computers & Internet Programming & Design

4 answers

To print to the VB debugger, this will work:
for x = 2 to 10 step 2
debug.print x
next

If you want it to go to a dialog box, just change the debug.print line to put the output there instead.

2007-01-10 15:53:05 · answer #1 · answered by Anonymous · 2 0

sure,
I am going to assume 2 to 10 inclusively.

for x= 2 to 10
remain=x mod 2
if remain=0 then print x
next

2007-01-10 15:25:38 · answer #2 · answered by Metaspy 3 · 0 0

You aren't specific in your question, but you may only need to create a label box and put a number in there.
If you are displaying a variable, dim it as an Integer, not a double, to come out as a whole number and not a decimal.

2007-01-10 15:22:50 · answer #3 · answered by Matt L 2 · 0 1

Here i worked on it for 40 min and got it.
#include
using namespace std;

int main(void){
int gen;
int i = 0;
int arry[10];
arry[0] = 1;
arry[1] = 2;
arry[2] = 3;
arry[3] = 4;
arry[4] = 5;
arry[5] = 6;
arry[6] = 7;
arry[7] = 8;
arry[8] = 9;
arry[9] = 10;

int label= 1;
int even = 1;



cout << "NUMS 1-10\n";
for(gen = 0; gen <= 9; gen++){

cout << arry[i];
cout << endl;
i++;
}


cout << "RESULT EVEN #'s\n\n";
for(gen = 0; gen <= 4; gen++){
cout << label << ".";
cout << arry[even];
cout << endl;
label++;
even = even + 2;
}

system("PAUSE");
return (0);
}

2007-01-10 16:13:47 · answer #4 · answered by Best Helper 4 · 0 1

fedest.com, questions and answers