Anda di halaman 1dari 11

# Sub entrarmatriz(MAT() As Double, NFIL As Integer, NCOL As Integer)

## Dim I As Integer, J As Integer

ReDim MAT(NFIL, NCOL)
For I = 1 To NFIL
For J = 1 To NCOL
MAT(I, J) = Val(InputBox(I, J))
Next J
Next I
End Sub
Sub MOSTRARMATRIZ(MAT() As Double, NFIL As Integer, NCOL As Integer, LISTA As Object)
Dim I As Integer, J As Integer, FILA As String
LISTA.Clear
For I = 1 To NFIL
FILA = ""
For J = 1 To NCOL
FILA = FILA & MAT(I, J) & " "
Next J
Next I
End Sub
Sub sumarmatriz(MAT() As Double, b() As Double, C() As Double, NFIL As Integer, NCOL As
Integer)
Dim I As Integer, J As Integer
ReDim C(NFIL, NCOL)
For I = 1 To NFIL
For J = 1 To NCOL
C(I, J) = MAT(I, J) + b(I, J)
Next J

Next I
End Sub
Sub entrarvector(a() As Double, t As Integer)
Dim I As Integer
ReDim a(t)
For I = 1 To t
a(I) = Val(InputBox(I))
Next I
End Sub
Sub mostrarvector(a() As Double, t As Integer, LISTA As Object)
Dim I As Integer
LISTA.Clear
For I = 1 To t
Next I
End Sub
Sub sumarvector(a() As Double, b() As Double, C() As Double, t As Integer)
Dim I As Integer
ReDim C(t)
For I = 1 To t
C(I) = a(I) + b(I)
Next I
End Sub
Sub tablademultiplicar(IDARCHIVO As String, ntabla As Integer)
Dim I As Integer
Open IDARCHIVO For Output As 1
For I = 1 To 10
Print #1, ntabla; "X"; I; "="; ntabla * I

Next I
Close 1
End Sub
Sub leerdatos(idarchi As String, numerodatos As Integer, LISTA As Object)
Dim I As Integer, X As Double
LISTA.Clear
Open idarchi For Input As 1
For I = 1 To numerodatos
If EOF(1) = False Then
Input #1, X
End If
Next I
Close 1
End Sub
Sub todoslosdatos(idarchi As String, LISTA As Object)
Dim I As Integer, X As Double
LISTA.Clear
Open idarchi For Input As 1
While EOF(1) = False
Input #1, X
Wend
Close 1
End Sub
Sub contardatos(idarchi As String, LISTA As Object)
Dim C As Integer, X As Double
C=0

## Open idarchi For Input As 1

While EOF(1) = False
Input #1, X
C=C+1
Wend
Close 1
End Sub
ARCHIVO
Sub LEERMATRIZ(idarchi As String, MAT() As Double, nf As Integer, nc As Integer)
Dim I As Integer, J As Integer
Open idarchi For Input As 1
Input #1, nf, nc
ReDim MAT(nf, nc)
For I = 1 To nf
For J = 1 To nc
Input #1, MAT(I, J)
Next J
Next I
Close 1
End Sub
Sub MOSTRARMATRIZ(MAT() As Double, nf As Integer, nc As Integer, LISTA As Object)
Dim I As Integer, J As Integer, FILA As String
For I = 1 To nf
FILA = ""
For J = 1 To nc
FILA = FILA & MAT(I, J) & " "
Next J

Next I
End Sub
Sub sumarfilas(MAT() As Double, nf As Integer, nc As Integer, f1 As Integer, f2 As Integer)
Dim I As Integer
For I = 1 To nc
MAT(f1, I) = MAT(f1, I) + MAT(f2, I)
Next I
End Sub
Sub guardarmatriz(idarchi As String, MAT() As Double, nf As Integer, nc As Integer)
Dim I As Integer, J As Integer
Open idarchi For Output As 2
For I = 1 To nf
For J = 1 To nc
Print #2, MAT(I, J);
Next J
Print #2, ""
Next I
Close 2
End Sub
ARCHIVO
Sub leervector(idarchi As String, V() As Double, C As Integer)
Dim I As Integer, X As Double
Open idarchi For Input As 1
While EOF(1) = False
Input #1, X
C=C+1
Wend

Close 1
ReDim V(C)
Open idarchi For Input As 1
For I = 1 To C
Input #1, V(I)
Next I
Close 1
End Sub
Sub mostrarvector(V() As Double, C As Integer, LISTA As Object)
Dim I As Integer
LISTA.Clear
For I = 1 To C
Next I
End Sub
Sub buscar(buscado As Double, V() As Double, C As Integer, pos As Integer)
Dim I As Integer
For I = 1 To C
pos = I
Exit For
End If
Next I
End Sub
Sub repeticiones(buscado As Double, V() As Double, C As Integer, nr As Integer, vp() As
Double)
Dim I As Integer, J As Integer
nr = 0

For I = 1 To C
nr = nr + 1
End If
Next I
J=0
ReDim vp(nr)
For I = 1 To C
J=J+1
vp(J) = I
End If
Next I
End Sub
Sub selecciondatos(idarchi As String, multiplo As Integer)
Dim I As Integer, C As Integer, X As Double
Open idarchi For Input As 1
Open "D:\Mis documentos\Desktop\andres\7 seleccion\seleccion.txt" For Output As 2
I=0
C=0
While EOF(1) = False
I=I+1
Input #1, X
If X Mod multiplo = 0 Then
C=C+1
Print #2, X, I
End If
Wend

## Print #2, C, "datos seleccionados"

Close 1, 2
End Sub
Sub encontrardatos(idarchi As String, idarchi2 As String)
Open "D:\Mis documentos\Desktop\andres\7 seleccion\encontrados.txt" For Output As 3
Open idarchi2 For Input As 2
Dim I As Integer, X As Double, y As Double
While EOF(2) = False
I=0
Input #2, X
Open idarchi For Input As 1
While EOF(1) = False
Input #1, y
If X = y Then
I=I+1
Print #3, X, I
End If
Wend
Close 1
Wend
Close 2, 3
End Sub
Sub LEERMATRIZ(IDARCHIVO As String, MAT() As Double, NFIL As Integer, NCOL As Integer)
Dim I As Integer, J As Integer
Open IDARCHIVO For Input As 1
Input #1, NFIL, NCOL
ReDim MAT(NFIL, NCOL)
For I = 1 To NFIL

For J = 1 To NCOL
Input #1, MAT(I, J)
Next J
Next I
Close 1

End Sub
Sub MOSTRARMATRIZ(MAT() As Double, NFIL As Integer, NCOL As Integer, LIST As Object)
Dim I As Integer, J As Integer, FILA As String
LIST.Clear
For I = 1 To NFIL
FILA = " "
For J = 1 To NCOL
FILA = FILA & MAT(I, J) & " "
Next J
Next I

End Sub
Sub PROMEDIARMATRIZ(MAT() As Double, NFIL As Integer, NCOL As Integer, TEXT As Object,
P As Double)
Dim C As Integer, I As Integer, J As Integer, S As Double, X As Double

C = NFIL * NCOL

X=0
For I = 1 To NFIL
S=0

For J = 1 To NCOL
S = S + MAT(I, J)
Next J
X=X+S
Next I
P=X/C
TEXT = P

End Sub
Sub CREARVECTOR(MAT() As Double, NFIL As Integer, NCOL As Integer, V() As Double, P As
Double, LISTA As Object)
Dim C As Integer, I As Integer, J As Integer, K As Integer, L As Integer

C=0
For I = 1 To NFIL
For J = 1 To NCOL
If P > MAT(I, J) Then
C=C+1
End If
Next J
Next I

ReDim V(C)
C=0
For I = 1 To NFIL
For J = 1 To NCOL
If P < MAT(I, J) Then

C=C+1
V(C) = MAT(I, J)
End If
Next J
Next I

LISTA.Clear
For I = 1 To C