Bienvenido: ( Identificarse | Registrarse )      
Foros de Trucos Windows
Closed TopicStart new topicStart Poll

Outline · [ Estándar ] · Lineal+

> Ayuda con Visual Basic >_<!, Me fallan los codigos T_T

ArknGL
post Jun 27 2006, 02:07 PM
Publicado: #1


Newbie
*

Grupo: Members
Mensajes: 2
Registrado: 27-June 06
Miembro nº: 172.155



Bueno, me dejaron un trabajo pal cole cry1at.gif en Visual, era simple una presentación sobre un tema "X", y luego hacer 10 preguntas sobre el tema, cada una con 4 opciones , para k luego salga una tabla con los resultados
Aca subi los screen >_<!

imagen externa


Lo termine de diseñar, y va todo correcto, hasta cuando tiene que salir la tabla y seleccionar los puntos de cada pregunta T_T

imagen externa


Pongamos un ejemplo de como yo he puesto los codigos

Pregunta: ¿Cuanto es 1 + 1? (en Label)
En opt, 4 opciones:
O 2(optP1, Index 0) / O 3(optP1, Index 1)
O 4(optP1, Index 2) / O 4(optP1, Index 3)

En el boton que se debe hacer click para sacar el puntaje he puesto:

Private Sub Command1_Click()
If optP1(0).Value = True Then
P1 = 2
Else
P1 = -1
End If
frmPregunta10.Show
Unload Me
End Sub

Y este es código del timer que le puse
Private Sub Timer1_Timer()
frmPregunta2.Show
Unload Me
End Sub

y asi se repiten en todas la preguntas, Aparte de eso, puse un Modulo general con el siguiente código:
Global P1, P2, P3, P4, P5, P6, P7, P8, P9, P10 As Double

Y no se en que me e confundido sad.gif , por favor si alguien me puede ayudar se lo agradecería.




User is offlineProfile CardPM
Go to the top of the page
+Quote Post
CyberMiniYo
post Jun 27 2006, 04:25 PM
Publicado: #2


Newbie
*

Grupo: Members
Mensajes: 7
Registrado: 27-June 06
Miembro nº: 172.150



Buenas, no soy un maestro pero tampoco me manejo mal en Visual.

Con la descripción del programa no llego a entender muy bien que es lo que quieres hacer. notengoidea.gif

Para qué necesitas el timer? confused.gif

En la tabla de resultados supongo que querrás sacar una puntuación, no?

En la segunda imagen no se ve el código del form_load, que es donde te dá el error, si lo enseñas podría ver mejor que es lo que falla.

Espero poder ayudarte. thumbsup.gif


User is offlineProfile CardPM
Go to the top of the page
+Quote Post
ArknGL
post Jun 27 2006, 06:26 PM
Publicado: #3


Newbie
*

Grupo: Members
Mensajes: 2
Registrado: 27-June 06
Miembro nº: 172.155



Tengo que hacer un trabajo, un tipo examen de 10 preguntas con 4 opciones cada uno biggrin.gif . Lo complicada para mi es sumar los puntos y ponerlos en la tabla de puntuación. matlingua5bi.gif . Utilizo el timer para que contestes con tiempo, que tu razonamiento sea rápido, sino pasa a la otra pregunta

aka pongo los códigos k utilize:
Este código se repite 10 veces, solo que se modifica el nombre del opt(P2,P3,P4, etx, hasta optP10)
Private Sub cmdSiguiente_Click()
If optP1(0).Value = True Then
P1 = 2
Else
P1 = -1
End If
frmPregunta2.Show
Unload Me
End Sub

y este es el codigo del timer, que solo se modifica el nombre del formulario que va a abrir
Private Sub Timer1_Timer()
frmPregunta2.Show
Unload Me
End Sub

Codigos del form load:
Private Sub Form_Load()
Dim PT As Integer
txtPr1.Text = P1
txtPr2.Text = P2
txtPr3.Text = P3
txtPr4.Text = P4
txtPr5.Text = P5
txtPr6.Text = P6
txtPr7.Text = P7
txtPr8.Text = P8
txtPr9.Text = P9
txtPr10.Text = P10

PT = P1 + P2 + P3 + P4 + P5 + P6 + P7 + P8 + P9 + P10
txtTotal = PT
End Sub

Códigos del Modulo:
Global P1, P2, P3, P4, P5, P6, P7, P8, P9, P10 As Double

Gracias por su ayuda de antemano



User is offlineProfile CardPM
Go to the top of the page
+Quote Post
rob1104
post Jun 27 2006, 08:14 PM
Publicado: #4


Xbox Live... The best thing ever happened around videogames
Group Icon

Grupo: Moderadores
Mensajes: 1.665
Registrado: 7-March 05
Desde: Matamoros, Tamaulipas, Mexico
Miembro nº: 93.342



Hola, si queda algo claro pero aun esta un poco confuso, , pues ya hice una prueba y el codigo parece estar bien excepto las variables de modulo pero eso no influye
CODE
Global P1, P2, P3, P4, P5, P6, P7, P8, P9, P10 As Double

Ahi solamente p10 es double, las demas son variant tongue.gif, por cierto postea todo el proyecto, subelo a rapidshare, megaupload o algo similar y con gusto te ayudo

salu2 bye1.gif
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
CyberMiniYo
post Jun 28 2006, 05:26 PM
Publicado: #5


Newbie
*

Grupo: Members
Mensajes: 7
Registrado: 27-June 06
Miembro nº: 172.150



Ok, ya entendí lo que necesitas. clap.gif

Primero, siento contradecir a "robbie", pero creo que sí que están bien definidas las variables separadas por coma y al final "as Double", a mí me funciona.

ArknGL, creo que el problema está en que las defines como "global" y a mí eso me da problemas, prueba con "public" y supongo que ya tendrás solucionado el fallo en la carga del formulario con la tabla de resultados.

De todas formas, si aún tienes problemas porque no era la solución correcta, prueba a postear el código como dice robbie y a lo mejor te podemos ayudar. wink.gif
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
rob1104
post Jun 28 2006, 06:26 PM
Publicado: #6


Xbox Live... The best thing ever happened around videogames
Group Icon

Grupo: Moderadores
Mensajes: 1.665
Registrado: 7-March 05
Desde: Matamoros, Tamaulipas, Mexico
Miembro nº: 93.342



QUOTE
Primero, siento contradecir a "robbie", pero creo que sí que están bien definidas las variables separadas por coma y al final "as Double", a mí me funciona.

Negativo amigo, mira al hacer esto:
CODE
global P1,P2,P3,P4 as double

Lo que estas declarando es:
P1=variant
P2=Variant
P3=Variant
P4=Double

http://www.mundoprogramacion.com/vb/cursos...co/basico02.htm

Creo que ver para creer smile.gif
CODE
Option Explicit
Private Sub Form_Load()
   Dim a, b, c As String, d
   Show
   a = 6
   b = 9
   c = 8
   d = "pescado"
   Print a + c + d
End Sub

Si te compila sin error me dices smile.gif

Por cierto Variant acepta de todo pero consume mas memoria

Salu2

PD: Talvez si sea eso de cambiar global a public, lo probare...
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
Closed TopicTopic OptionsStart new topic

Collapse

> Topicos similares

ayuda con spore angkok 25 1 Ayer, 10:33 PM
By: RedPhoenix
AYUDA PARA TOM CLANCY RSV 2 juanma243 112 5 Ayer, 10:14 PM
By: RedPhoenix
AYUDA! ferduo 35 1 Ayer, 09:27 PM
By: patricioirrazabal
ayuda xfa vileichon 94 5 Ayer, 03:23 PM
By: Vera
Error de subsistema. Ya probé lo leido en otro ... chewy123 67 0 Ayer, 09:13 AM
By: chewy123