Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21993

Global/ public array problem

$
0
0
Hello guys, Im trying to develop a visualizer for a program that i have made before, i made some kind of searcher but one i get an array and try to use it in a different instance it shows an erres, i would appreciate any kind of help, thanks.

the error is when i try to use the array B() on the command 2 click, it says the subindex is out of the bound. any idea?


here's the code

Public num As Integer
Public tope As Integer
Public ruta As String
Public nactivo As String
Private Sub Command1_Click()
num = num + 1
If num >= tope Then
Command1.Enabled = False
Else
If (num >= 1 And num <= (tope - 1)) Then
Command1.Enabled = True
Command2.Enabled = True
End If
End If
Label2.Caption = num
End Sub
Public Sub Command2_Click()
num = num - 1
If num <= 0 Then
Command2.Enabled = False
Else
If (num >= 1 And num <= (tope - 1)) Then
Command1.Enabled = True
Command2.Enabled = True
End If
End If

Label2.Caption = num

OLE1.SourceDoc = ruta & "\" & nactivo & B(num)
OLE1.CreateEmbed ruta & "\" & nactivo & B(num)
OLE1.Update
End Sub

Public Sub Command3_Click()

Dim fso As New Scripting.FileSystemObject
Dim fld As Scripting.Folder
Dim fil As Scripting.File
Dim lngCount As Long
Dim count As Integer
Dim num As Integer
Dim A() As String
Dim arreglo(29) As String
Dim B() As String




arreglo(0) = "C:\SDOM\Caldera y auxiliares\aceite liviano"
arreglo(1) = "C:\SDOM\Caldera y auxiliares\Agua alimentacion"
arreglo(2) = "C:\SDOM\Caldera y auxiliares\Agua de circulacion"
arreglo(3) = "C:\SDOM\Caldera y auxiliares\Aire y gases de combustion"
arreglo(4) = "C:\SDOM\Caldera y auxiliares\Caldera"
arreglo(5) = "C:\SDOM\Caldera y auxiliares\Condensado principal"
arreglo(6) = "C:\SDOM\Caldera y auxiliares\Dosificador quimico"
arreglo(7) = "C:\SDOM\Caldera y auxiliares\Gas natural"
arreglo(8) = "C:\SDOM\Caldera y auxiliares\Manejo de ceniza"
arreglo(9) = "C:\SDOM\Caldera y auxiliares\Manejo y quemado de carbon"
arreglo(10) = "C:\SDOM\Caldera y auxiliares\Sopladores de hollin"
arreglo(11) = "C:\SDOM\Caldera y auxiliares\Tratamiento de agua"
arreglo(12) = "C:\SDOM\Caldera y auxiliares\Vapor auxiliar"
'-----
arreglo(13) = "C:\SDOM\Miscelaneos y auxiliares\Control automatico planta"
arreglo(14) = "C:\SDOM\Miscelaneos y auxiliares\Control ambiental"
arreglo(15) = "C:\SDOM\Miscelaneos y auxiliares\Comunicaciones planta"
arreglo(16) = "C:\SDOM\Miscelaneos y auxiliares\Drenaje planta"
arreglo(17) = "C:\SDOM\Miscelaneos y auxiliares\Agua enfriamiento cojinetes"
arreglo(18) = "C:\SDOM\Miscelaneos y auxiliares\Agua y servicio de agua potable"
arreglo(19) = "C:\SDOM\Miscelaneos y auxiliares\Aire comprimido e instrumentos"
arreglo(20) = "C:\SDOM\Miscelaneos y auxiliares\Alumbrado"
arreglo(21) = "C:\SDOM\Miscelaneos y auxiliares\Contraincendio"
arreglo(22) = "C:\SDOM\Miscelaneos y auxiliares\Edificio y vias"
arreglo(23) = "C:\SDOM\Miscelaneos y auxiliares\Equipos y herramientas talleres"
arreglo(24) = "C:\SDOM\Miscelaneos y auxiliares\Transporte carga"
'-----
arreglo(25) = "C:\SDOM\Turbogenerador y auxiliares\Bypass alta y baja presion"
arreglo(26) = "C:\SDOM\Turbogenerador y auxiliares\Generador"
arreglo(27) = "C:\SDOM\Turbogenerador y auxiliares\Potencia electrica"
arreglo(28) = "C:\SDOM\Turbogenerador y auxiliares\Turbina"
arreglo(29) = "C:\SDOM\Turbogenerador y auxiliares\Vapor sello y vacio condensador"









Dim numactivo() As Integer


count = 0
sal = 0
lngCount = 0
For i = 0 To 29



Set fld = fso.GetFolder(arreglo(i))

For Each fil In fld.Files
count = count + 1
ReDim A(count)
A(count) = fil.Name
nactivo = Left(A(count), 6)



auxnombre = fso.GetFileName(fil.Path)
auxnombre2 = Left(auxnombre, 6)


If auxnombre2 = text1.Text Then
lngCount = lngCount + 1

ReDim B(lngCount)

aux7 = Len(A(count))
aux8 = aux7 - 6
aux9 = Right(A(count), aux8)


B(lngCount) = aux9

MsgBox B(lngCount)

tope = lngCount
End If



If nactivo = text1.Text Then
ruta = arreglo(i)
numarchivos = lngCount
Archivo = A(count)



End If

'MsgBox A(count)

Next fil


Next i

MsgBox numarchivos
MsgBox ruta



Set fil = Nothing
Set fld = Nothing
Set fso = Nothing
MsgBox lngCount
num = count

OLE1.SourceDoc = ruta & "\" & Archivo
OLE1.CreateEmbed ruta & "\" & Archivo
OLE1.Update

End Sub

Viewing all articles
Browse latest Browse all 21993

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>