Visual Basic - problemas con select case.........

Life is soft - evento anual de software empresarial
   
Vista:

problemas con select case.........

Publicado por cristopher (1 intervención) el 14/09/2016 23:20:48
hola compañeros estoy comenzando con esto de visual basic y pues donde si estoy mas fuerte es en matlab pero aqui cambia mucho el idioma, sin embargo al usar el comando select case algo raro pasa que unicamente me corre el programa el primer caso alguien me podria ayudar para saber que es lo q pasa.......... este es el comando,tiene un if al iniciio pero este si esta funcionanado bien

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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
Sub grafica()
 
Select Case b
Case b = "VPPT"
    ActiveSheet.Shapes.AddChart2(240, xlXYScatter).Select
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.FullSeriesCollection(1).Name = "=""VPPT"""
    ActiveChart.FullSeriesCollection(1).XValues = "=Hoja1!D2:D10"
    ActiveChart.FullSeriesCollection(1).Values = "=Hoja1!E2:E10"
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.FullSeriesCollection(2).Name = "=""norma1"""
    ActiveChart.FullSeriesCollection(2).XValues = "=Hoja1!K9:K14"
    ActiveChart.FullSeriesCollection(2).Values = "=Hoja1!J9:J14"
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.FullSeriesCollection(3).Name = "=""norma2"""
    ActiveChart.FullSeriesCollection(3).XValues = "=Hoja1!K16:K21"
    ActiveChart.FullSeriesCollection(3).Values = "=Hoja1!J16:J21"
    ActiveChart.FullSeriesCollection(3).Select
    With Selection.Format.Line
        .Visible = msoTrue
        .ForeColor.RGB = RGB(91, 155, 213)
    End With
    ActiveChart.FullSeriesCollection(2).Select
    With Selection.Format.Line
        .Visible = msoTrue
        .ForeColor.RGB = RGB(91, 155, 213)
    End With
    ActiveChart.Axes(xlCategory).Select
    With Selection.Format.Line
        .Visible = msoTrue
        .ForeColor.RGB = RGB(91, 155, 213)
    End With
    ActiveChart.Axes(xlCategory).ScaleType = xlLogarithmic
    ActiveChart.Axes(xlValue).Select
    ActiveChart.Axes(xlValue).ScaleType = xlLogarithmic
 
Case b = "VPPL"
    ActiveSheet.Shapes.AddChart2(240, xlXYScatter).Select
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.FullSeriesCollection(1).Name = "=""VPPL"""
    ActiveChart.FullSeriesCollection(1).XValues = "=Hoja1!B2:B10"
    ActiveChart.FullSeriesCollection(1).Values = "=Hoja1!C2:C10"
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.FullSeriesCollection(2).Name = "=""norma1"""
    ActiveChart.FullSeriesCollection(2).XValues = "=Hoja1!K9:K14"
    ActiveChart.FullSeriesCollection(2).Values = "=Hoja1!J9:J14"
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.FullSeriesCollection(3).Name = "=""norma2"""
    ActiveChart.FullSeriesCollection(3).XValues = "=Hoja1!K16:K21"
    ActiveChart.FullSeriesCollection(3).Values = "=Hoja1!J16:J21"
    ActiveChart.FullSeriesCollection(3).Select
    With Selection.Format.Line
        .Visible = msoTrue
        .ForeColor.RGB = RGB(91, 155, 213)
    End With
    ActiveChart.FullSeriesCollection(2).Select
    With Selection.Format.Line
        .Visible = msoTrue
        .ForeColor.RGB = RGB(91, 155, 213)
    End With
    ActiveChart.Axes(xlCategory).Select
    With Selection.Format.Line
        .Visible = msoTrue
        .ForeColor.RGB = RGB(91, 155, 213)
    End With
    ActiveChart.Axes(xlCategory).ScaleType = xlLogarithmic
    ActiveChart.Axes(xlValue).Select
    ActiveChart.Axes(xlValue).ScaleType = xlLogarithmic
 
Case b = "VPPV"
    ActiveSheet.Shapes.AddChart2(240, xlXYScatter).Select
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.FullSeriesCollection(1).Name = "=""VPPV"""
    ActiveChart.FullSeriesCollection(1).XValues = "=Hoja1!F2:F10"
    ActiveChart.FullSeriesCollection(1).Values = "=Hoja1!G2:G10"
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.FullSeriesCollection(2).Name = "=""norma1"""
    ActiveChart.FullSeriesCollection(2).XValues = "=Hoja1!K9:K14"
    ActiveChart.FullSeriesCollection(2).Values = "=Hoja1!J9:J14"
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.FullSeriesCollection(3).Name = "=""norma2"""
    ActiveChart.FullSeriesCollection(3).XValues = "=Hoja1!K16:K21"
    ActiveChart.FullSeriesCollection(3).Values = "=Hoja1!J16:J21"
    ActiveChart.FullSeriesCollection(3).Select
    With Selection.Format.Line
        .Visible = msoTrue
        .ForeColor.RGB = RGB(91, 155, 213)
    End With
    ActiveChart.FullSeriesCollection(2).Select
    With Selection.Format.Line
        .Visible = msoTrue
        .ForeColor.RGB = RGB(91, 155, 213)
    End With
    ActiveChart.Axes(xlCategory).Select
    With Selection.Format.Line
        .Visible = msoTrue
        .ForeColor.RGB = RGB(91, 155, 213)
    End With
    ActiveChart.Axes(xlCategory).ScaleType = xlLogarithmic
    ActiveChart.Axes(xlValue).Select
    ActiveChart.Axes(xlValue).ScaleType = xlLogarithmic
 
Case b = "todas"
    ActiveSheet.Shapes.AddChart2(240, xlXYScatter).Select
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.FullSeriesCollection(1).Name = "=""VPPL"""
    ActiveChart.FullSeriesCollection(1).XValues = "=Hoja1!B2:B10"
    ActiveChart.FullSeriesCollection(1).Values = "=Hoja1!C2:C10"
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.FullSeriesCollection(2).Name = "=""VPPT"""
    ActiveChart.FullSeriesCollection(2).XValues = "=Hoja1!D2:D10"
    ActiveChart.FullSeriesCollection(2).Values = "=Hoja1!E2:E10"
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.FullSeriesCollection(3).Name = "=""VPPV"""
    ActiveChart.FullSeriesCollection(3).XValues = "=Hoja1!F2:F10"
    ActiveChart.FullSeriesCollection(3).Values = "=Hoja1!G2:G10"
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.FullSeriesCollection(4).Name = "=""norma1"""
    ActiveChart.FullSeriesCollection(4).XValues = "=Hoja1!K9:K14"
    ActiveChart.FullSeriesCollection(4).Values = "=Hoja1!J9:J14"
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.FullSeriesCollection(5).Name = "=""norma2"""
    ActiveChart.FullSeriesCollection(5).XValues = "=Hoja1!K16:K21"
    ActiveChart.FullSeriesCollection(5).Values = "=Hoja1!J16:J21"
    ActiveChart.FullSeriesCollection(5).Select
    With Selection.Format.Line
        .Visible = msoTrue
        .ForeColor.RGB = RGB(91, 155, 213)
    End With
    ActiveChart.FullSeriesCollection(4).Select
    With Selection.Format.Line
        .Visible = msoTrue
        .ForeColor.RGB = RGB(91, 155, 213)
    End With
    ActiveChart.Axes(xlCategory).Select
    With Selection.Format.Line
        .Visible = msoTrue
        .ForeColor.RGB = RGB(91, 155, 213)
    End With
    ActiveChart.Axes(xlCategory).ScaleType = xlLogarithmic
    ActiveChart.Axes(xlValue).Select
    ActiveChart.Axes(xlValue).ScaleType = xlLogarithmic
End Select
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

problemas con select case.........

Publicado por Antoni Masana (190 intervenciones) el 15/09/2016 10:12:53
Mira esta pagina

https://msdn.microsoft.com/es-es/library/cy37t14y.aspx

Explica como utilizar el Select Case

De todas formas te hago un resumen a tu texto:

1
2
3
4
5
6
7
8
9
10
11
12
Sub grafica()
    Select Case b
        Case "VPPT"
           ...
        Case "VPPL"
           ...
        Case "VPPV"
           ...
        Case "todas"
           ...
    End Select
End Sub

Esta es la sintaxis correcta
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