Visual Basic - ¿bug en visual basic?

Life is soft - evento anual de software empresarial
 
Vista:

¿bug en visual basic?

Publicado por juan (13 intervenciones) el 27/08/2016 18:39:54
hola, tengo una duda es que esto haciendo un programa de visual basic es un ejercicio de la escuena el tema es de "compra de repuestos de autos",mi problema es que cuando quiero elegir una imagen me que esta en visible= false y se supone que cuando la busque se pone en =true pero hay veses que no y se me queda una imagen en true y las demas no aparesen
este es el codigo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
Private Sub Combo1_Click()
   If Combo1.Text = "FIAT" Then
        cmd_peugeot.Visible = False
        cmd_fiat.Visible = True
    ElseIf Combo1.Text = "PEUGEOT" Then
        cmd_peugeot.Visible = True
        cmd_fiat.Visible = False
    End If
End Sub
Private Sub Command1_Click()                          'con testo es el problema
    Image1.Left = 2147
    If cmd_fiat = "ANILLO RESORTE SUSPENSION REGATTA M/N" Then
        Image2.Visible = True
        Image3.Visible = False
        Image6.Visible = False
        Image5.Visible = False
    ElseIf cmd_fiat = "SOPORTE TIRANTE PALANCA CAMBIO DUNA UNO" Then
        Image3.Visible = True
        Image6.Visible = False
        Image5.Visible = False
        Image2.Visible = False
    End If
    If cmd_peugeot = "ABRAZADERA FILTRO GASOIL 206 306 PARTNER DW8" Then
        Image5.Visible = True
        Image2.Visible = False
        Image3.Visible = False
        Image6.Visible = False
    ElseIf cmd_peugeot = "POLEA CIGUEÑAL PEUGEOT 504 505 3 CANALES" Then
        Image6.Visible = True
        Image5.Visible = False
        Image2.Visible = False
        Image3.Visible = False
    End If
End Sub
Private Sub Command2_Click()
    total = Text4.Text * Text1.Text
    Text2 = total
End Sub
Private Sub Command3_Click()
List1.RemoveItem (List1.ListIndex)
End Sub
Private Sub Command4_Click()
    List1.AddItem Text2.Text
    Text4 = ""
    Text1 = ""
    Text2 = ""
End Sub
Private Sub Command5_Click()
    Dim i As Integer
    Dim total As Long
    total = 0
    For i = 0 To List1.ListCount - 1
        total = total + Val(List1.List(i))
    Next i
    Text3.Text = total
End Sub
Private Sub Command6_Click()
Dim descuento As Double
    If Text5.Text = "ve3sox21" Then
        descuento = 0.85 * Text3.Text
        Text6.Text = descuento
    ElseIf Text5.Text = "xowb920" Then
        descuento = 0.7 * Text3.Text
        Text6.Text = descuento
    Else
        Label6.Visible = True
    End If
End Sub
Private Sub Image1_DragDrop(Source As Control, X As Single, Y As Single)
    If Source = Image2 Then
        total = total + 28
    ElseIf Source = Image3 Then
        total = total + 347
    ElseIf Source = Image4 Then
        total = total + 103
    ElseIf Source = Image5 Then
        total = total + 177
    ElseIf Source = Image6 Then
        total = total + 512
    ElseIf Source = Image7 Then
        total = total + 608
    End If
    Text4.Text = total
End Sub
Private Sub Label5_Click()
Text5.Visible = True
Text6.Visible = True
Command6.Visible = True
End Sub
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Antoni Masana
Val: 1.259
Plata
Ha mantenido su posición en Visual Basic (en relación al último mes)
Gráfica de Visual Basic

¿bug en visual basic?

Publicado por Antoni Masana (558 intervenciones) el 30/08/2016 12:58:32
Esto que te pongo no hace que funcione mejor pero es más corto hace lo mismo y es más leible

1
2
3
4
5
6
7
8
9
10
11
12
13
Private Sub Command1_Click()                          'con testo es el problema
    Image1.Left = 2147
 
    Image2.Visible = False
    Image3.Visible = False
    Image6.Visible = False
    Image5.Visible = False
 
    If cmd_fiat    = "ANILLO RESORTE SUSPENSION REGATTA M/N"        Then  Image2.Visible = True
    If cmd_fiat    = "SOPORTE TIRANTE PALANCA CAMBIO DUNA UNO"      Then  Image3.Visible = True
    If cmd_peugeot = "ABRAZADERA FILTRO GASOIL 206 306 PARTNER DW8" Then  Image5.Visible = True
    If cmd_peugeot = "POLEA CIGUEÑAL PEUGEOT 504 505 3 CANALES"     Then  Image6.Visible = True
End Sub


No se que es cmd_fiat ni que valor tiene. Podrias hacer esto:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Private Sub Command1_Click()                          'con testo es el problema
    Image1.Left = 2147
 
MsgBox "Fiat: " & cmd.fiat & vbcrlf & "Peugeot: " & cmd_peugeot
 
    Image2.Visible = False
    Image3.Visible = False
    Image6.Visible = False
    Image5.Visible = False
 
    If cmd_fiat    = "ANILLO RESORTE SUSPENSION REGATTA M/N"        Then  Image2.Visible = True
    If cmd_fiat    = "SOPORTE TIRANTE PALANCA CAMBIO DUNA UNO"      Then  Image3.Visible = True
    If cmd_peugeot = "ABRAZADERA FILTRO GASOIL 206 306 PARTNER DW8" Then  Image5.Visible = True
    If cmd_peugeot = "POLEA CIGUEÑAL PEUGEOT 504 505 3 CANALES"     Then  Image6.Visible = True
End Sub

En teoria deberias de ver 1 de los 4 textos del IF para activar solo 1 de las imágenes

Si ves 2 textos quiere decir que se activan dos imágenes una de FIAT y otra de Peugeot

Si lo que deseas es que se vea una imagen, una solución podría ser esta si no me equivoco:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Private Sub Command1_Click()                          'con testo es el problema
    Image1.Left = 2147
 
    Image2.Visible = False
    Image3.Visible = False
    Image6.Visible = False
    Image5.Visible = False
 
    if cmd_fiat.Visible Then
       If cmd_fiat    = "ANILLO RESORTE SUSPENSION REGATTA M/N"        Then  Image2.Visible = True
       If cmd_fiat    = "SOPORTE TIRANTE PALANCA CAMBIO DUNA UNO"      Then  Image3.Visible = True
    end if
 
    if cmd_peugeot.Visible Then
       If cmd_peugeot = "ABRAZADERA FILTRO GASOIL 206 306 PARTNER DW8" Then  Image5.Visible = True
       If cmd_peugeot = "POLEA CIGUEÑAL PEUGEOT 504 505 3 CANALES"     Then  Image6.Visible = True
    end if
End Sub

o más simple:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Private Sub Command1_Click()                          'con testo es el problema
    Image1.Left = 2147
 
    Image2.Visible = False
    Image3.Visible = False
    Image6.Visible = False
    Image5.Visible = False
 
    if cmd_fiat.Visible Then
       If cmd_fiat    = "ANILLO RESORTE SUSPENSION REGATTA M/N"        Then  Image2.Visible = True
       If cmd_fiat    = "SOPORTE TIRANTE PALANCA CAMBIO DUNA UNO"      Then  Image3.Visible = True
    else
       If cmd_peugeot = "ABRAZADERA FILTRO GASOIL 206 306 PARTNER DW8" Then  Image5.Visible = True
       If cmd_peugeot = "POLEA CIGUEÑAL PEUGEOT 504 505 3 CANALES"     Then  Image6.Visible = True
    end if
End Sub

Saludos
\\//_
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar