Como utilizar el comando IF
jdlopaloteTarea13 de Marzo de 2019
1.894 Palabras (8 Páginas)134 Visitas
UNIVERSIDAD DOMINICANA O&M 1
Saber – Pensar – Trabajar
Sección:
Profesor: Jose Luís Amberes
Periodo: Mayo - Agosto 2018
Amberes2004hotmail.com
PRACTICAR EN EL CENTRO EDUCACIONAL DE COMPUTOS
1 - DECLARAR VARIABLES E IMPRIMIRLAS
int numero;
string nombre;
n = 1;
nombre = "maria";
MessageBox.Show(n.ToString()+""+nombre);
2 - DECLARAR VARIABLES Y MOSTRARLAS EN UNA CAJA DE TEXTO
Dim nombre As String
nombre = "mria"
textBox1.Text = nombre;
3 – SUBSTRAER UNA PARTE DE UNA CADENA
Dim nombre As String
nombre = "mria"
textBox1.Text = nombre.Substring(0,2);
4 – SUBSTRAER UNA PARTE DE UNA CADENA
textBox2.Text = textBox1.Text.Substring(4,2);
if (textBox2.Text=="IS") textBox3.Text= "SISTEMA";
if (textBox2.Text == "CT") textBox3.Text = "CONTA";
5 – BUCLE PARA IMPRIMIR LOS NUMEROS DEL 1 A L 5 CON UN MSGBOX UTILIZANDO EL BUCLE FOR
int numero;
for (numero = 1; numero <= 3; numero++)
{
MessageBox.Show(numero.ToString());
}
UNIVERSIDAD DOMINICANA O&M 2
Saber – Pensar – Trabajar
Sección:
Profesor: Jose Luís Amberes
Periodo: Mayo - Agosto 2018
Amberes2004hotmail.com
PRACTICAR EN EL CENTRO EDUCACIONAL DE COMPUTOS
6 – BUCLE PARA IMPRIMIR 5 VECES UN MENSAJE DENTRO DE UN LISTBOX
int numero;
for (numero = 1; numero <= 3; numero++)
{
MessageBox.Show("numero");
}
7 – BUCLE PARA IMPRIMIR 5 VECES 2 MENSAJES DENTRO DE UN LISTBOX
int numero;
for (numero = 1; numero <= 3; numero++)
{
MessageBox.Show("hola " + "mundo ");
}
8 – BUCLE PARA IMPRIMIR 5 VECES 2 MENSAJES Y UN NUMERO DENTRO DE UN LISTBOX
int n;
for (n = 1; n <= 3; n++){
MessageBox.Show("hola " + "mundo " + n.ToString());}
9 – BUCLE PARA IMPRIMIR NUMEROS DEL 1 AL 5 DENTRO DE UN LISTBOX
int numero;
for (numero = 1; numero <= 3; numero++){ listBox1.Items.Add(numero.ToString());}
UNIVERSIDAD DOMINICANA O&M 3
Saber – Pensar – Trabajar
Sección:
Profesor: Jose Luís Amberes
Periodo: Mayo - Agosto 2018
Amberes2004hotmail.com
PRACTICAR EN EL CENTRO EDUCACIONAL DE COMPUTOS
10 – COMO UTILIZAR EL COMANDO IF
int n;
n=2;
if (n==2) textBox1.Text ="dos";
11 – COMO UTILIZAR EL COMANDO IF ELSE
int n;n=3;
if (n==2)
textBox1.Text ="dos";
else
textBox1.Text = "diferente de dos";
12 – COMO UTILIZAR EL COMANDO IF ELSE
int n;
for (n = 1; n <= 5; n++){
if(n==4)
listBox1.Items.Add("cuatro");
else
listBox1.Items.Add(n.ToString());}
13 – COMO UTILIZAR EL COMANDO IF
int n;
for (n = 1; n <= 5; n++){
if(n>2) listBox1.Items.Add(n.ToString());}
UNIVERSIDAD DOMINICANA O&M 4
Saber – Pensar – Trabajar
Sección:
Profesor: Jose Luís Amberes
Periodo: Mayo - Agosto 2018
Amberes2004hotmail.com
PRACTICAR EN EL CENTRO EDUCACIONAL DE COMPUTOS
14 – COMO UTILIZAR EL SIGNO != significa distinto
int n;
for (n = 1; n <= 5; n++){
if(n!=2) listBox1.Items.Add(n.ToString());}
15 –COMO DETERMINAR CUANTAS VECES SE REPITE UNA LETRA , EN ESTA CASO LETRA E
string nombre="PEPE"; int n = 0; int c = 0;
for (n = 0; n <= 3; n++)
if(nombre.Substring(n,1)=="E") c=c+1;
listBox1.Items.Add(" " +c.ToString());
16 – COMO UTILIZAR EL COMANDO LENGTH Y SUBSTRING AVANZADO
string nombre=textBox1.Text; int n=0; int c=0; int t=0;
t = nombre.Length-1;
for (n = 0; n <= t; n++)
if(nombre.Substring(n,1)=="E") c=c+1;
listBox1.Items.Add(" " +c.ToString());
17 – CRAR UNA TABLA DE MULTIMPLICAR CON UN BUCLE
int n=0;
for (n = 1; n <= 5; n++){
listBox1.Items.Add(" 5 x " + n.ToString() + "=" + (n * 5).ToString()); }
18 – COMO UTILIZAR EL BUCLE CON UNA TABLA Y QUE NO SALGA UNA FILA ESPECIFICA
int contador=0;
int n=0;
string nombre="maria";
for (n = 1; n <= 5; n++){
if(n !=2) listBox1.Items.Add(" 5 x " + n.ToString() + "=" + (n * 5).ToString()); }
UNIVERSIDAD DOMINICANA O&M 5
Saber – Pensar – Trabajar
Sección:
Profesor: Jose Luís Amberes
Periodo: Mayo - Agosto 2018
Amberes2004hotmail.com
PRACTICAR EN EL CENTRO EDUCACIONAL DE COMPUTOS
19 – COMO UTILIZAR EL INPUTBOX CAJA DE ENTRADA DE DATOS) Encabezado debe tener
using Microsoft.VisualBasic;
string nombre;
nombre=Interaction.InputBox("nom","ti","valor", 100, 100);
MessageBox.Show(nombre);
20 – COMO UTILIZAR EL COMANDO INPUTBOX (ENTRADA DE DATOS) Y SUMAR 2 NUMEROS
string n1,n2; int resultado;
n1= Interaction.InputBox("numero1", "", "", 100, 100);
n2= Interaction.InputBox("numero2", "", "", 100, 100);
resultado = Convert.ToInt16(n1) + Convert.ToInt16(n2);
MessageBox.Show(resultado.ToString());
21 – PIDE EL DIA DE LA SEMANA E IMPRIME EL NOMBRE DEL DIA
string n1;
n1= Interaction.InputBox("Dia de Semana","","",100,100);
if(Convert.ToInt16(n1)==1) MessageBox.Show("Lunes");
if(Convert.ToInt16(n1)==2) MessageBox.Show("Martes");
if(Convert.ToInt16(n1)> 2) MessageBox.Show("Error");
...