← Foro de Visual Basic

Me podeis corregir este código...?

Hilo en el foro de Visual Basic · 31 de Enero del 2006 · 1 respuestas
Abel31 de Enero del 2006
Pregunta
Ya tengo hechas las conexiones dsd visual basic a acces, haciendo referencia a una tabla dnd estan todas las combinaciones, ahora me hace falta q intenteis ayudarme a pasar este codigo a visual basic ya q confundo C++ con visual (sorry)
Os lo agradeceria mucho ;)
Aqui esta el codigo q he hecho:

cont1=0 (contador de aciertos)
num1=1 (contador repetitivo del 1 al 45)
acert10=0 (acertantes de 10)
acert11=0 (acertantes de 11)
acert12=0 (acertantes de 12)
acert13=0 (acertantes de 13)
acert14=0 (acertantes de 14)
acert15=0 (acertantes de 15)
x=1 (contador)

Do

if textbox1 = ux then
cont1=cont1 +1;
end if
if textbox1 = ex then
cont1=cont1 +1;
end if
if textbox1 = dx then
cont1=cont1 +1;
end if
num1=num1 +1;

if textbox2 = ux then
cont1=cont1 +1;
end if
if textbox2 = ex then
cont1=cont1 +1;
end if
if textbox2 = dx then
cont1=cont1 +1;
end if
num1=num1 +1;

if textbox3 = ux then
cont1=cont1 +1;
end if
if textbox3 = ex then
cont1=cont1 +1;
end if
if textbox3 = dx then
cont1=cont1 +1;
end if
num1=num1 +1;

if textbox4 = ux then
cont1=cont1 +1;
end if
if textbox4 = ex then
cont1=cont1 +1;
end if
if textbox4 = dx then
cont1=cont1 +1;
end if
num1=num1 +1;

if textbox5 = ux then
cont1=cont1 +1;
end if
if textbox5 = ex then
cont1=cont1 +1;
end if
if textbox5 = dx then
cont1=cont1 +1;
end if
num1=num1 +1;

if textbox6 = ux then
cont1=cont1 +1;
end if
if textbox6 = ex then
cont1=cont1 +1;
end if
if textbox6 = dx then
cont1=cont1 +1;
end if
num1=num1 +1;

if textbox7 = ux then
cont1=cont1 +1;
end if
if textbox7 = ex then
cont1=cont1 +1;
end if
if textbox7 = dx then
cont1=cont1 +1;
end if
num1=num1 +1;

if textbox8 = ux then
cont1=cont1 +1;
end if
if textbox8 = ex then
cont1=cont1 +1;
end if
if textbox8 = dx then
cont1=cont1 +1;
end if
num1=num1 +1;

if textbox9 = ux then
cont1=cont1 +1;
end if
if textbox9 = ex then
cont1=cont1 +1;
end if
if textbox9 = dx then
cont1=cont1 +1;
end if
num1=num1 +1;

if textbox10 = ux then
cont1=cont1 +1;
end if
if textbox10 = ex then
cont1=cont1 +1;
end if
if textbox10 = dx then
cont1=cont1 +1;
end if
num1=num1 +1;

if textbox11 = ux then
cont1=cont1 +1;
end if
if textbox11 = ex then
cont1=cont1 +1;
end if
if textbox11 = dx then
cont1=cont1 +1;
end if
num1=num1 +1;

if textbox12 = ux then
cont1=cont1 +1;
end if
if textbox12 = ex then
cont1=cont1 +1;
end if
if textbox12 = dx then
cont1=cont1 +1;
end if
num1=num1 +1;

if textbox13 = ux then
cont1=cont1 +1;
end if
if textbox13 = ex then
cont1=cont1 +1;
end if
if textbox13 = dx then
cont1=cont1 +1;
end if
num1=num1 +1;

if textbox14 = ux then
cont1=cont1 +1;
end if
if textbox14 = ex then
cont1=cont1 +1;
end if
if textbox14 = dx then
cont1=cont1 +1;
end if
num1=num1 +1;

if textbox15 = ux then
cont1=cont1 +1;
end if
if textbox15 = ex then
cont1=cont1 +1;
end if
if textbox15 = dx then
cont1=cont1 +1;
end if
num1=num1 +1;

if cont1=10 then
acert10=acert10 + 1;
end if

if cont1=11 then
acert11=acert11 + 1;
end if

if cont1=12 then
acert12=acert12 + 1;
end if

if cont1=13 then
acert13=acert13 + 1;
end if

if cont1=14 then
acert14=acert14 + 1;
end if

if cont1=15 then
acert15=acert15 + 1;
end if


if num1 <> 45 && x <> 10 then
x = x +1;
num1 = 1;
end if





while num1 <> 45


comunicar cuantos acertantes de 10, 11, 12, 13, 14 y 15 han habido


Gracias

Respuestas 1

mvallejos31 de Enero del 2006
No se entiende muy bien, no se sabe de donde salen esas variables como ux, ex,dx, etc.
De todos modos, podrías usar un array de 1 a 15 de contadores
Dim Aciertos(1 to 15) as Integer

Luego haces

Aciertos(Cont1) = Aciertos(Cont1) + 1

Esta Instruccion reemplaza a los 15 condicionales

Algo parecido con los textbox, podrías usar un array de TextBox de 1 a 15.

Saludos
¿Buscas más hilos como este? Mira el foro de Visual Basic o usa el buscador.