Otra manera de hacerlo, en realidad hay muchas, podrias hacer lo mismo que en tu primer ejemplo y salir del loop con un contador que se incrementa en cada vuelta.
Código:
Private Sub Form_Load() Dim sData As String
Open "c:\test.txt" For Binary Access Read As #1 sData = Space(LOF(1)) Get #1, , sData sData = Split(sData, vbCrLf)(1) Close #1
Lindo ejemplo, la verdad hay muy poco de esto en la red, vi un ejemplo en PSC pero nada mas que eso. Aunque esta un poco crudo (falta funcionalidad) es un buen comienzo, la verdad es muy interesante, epero que continues agregandole cosas =).
'--------------------------------------------------------------------------------------- ' Module : mGetProcAddress ' DateTime : 06/10/2008 20:06 ' Author : Cobein ' Mail : cobein27@hotmail.com ' WebPage : http://www.advancevb.com.ar ' Member of : http://hackhound.org/ ' Purpose : GetProcAddress alternative function ' Usage : At your own risk ' Requirements: None ' Distribution: You can freely use this code in your own ' applications, but you may not reproduce ' or publish this code on any web site, ' online service, or distribute as source ' on any media without express permission. ' ' Reference : Based on ExtremeCoder sample [http://www.rohitab.com/discuss/lofiversion/index.php/t30773.html] ' ' History : 06/10/2008 First Cut.................................................... ' 06/10/2008 Minor change in buffer size to increase speed................ '--------------------------------------------------------------------------------------- Option Explicit
Private Declare Function LoadLibraryA Lib "kernel32" (ByVal lpLibFileName As String) As Long Private Declare Sub GetMem4 Lib "msvbvm60" (ByVal Addr As Long, RetVal As Long) Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As String) As Long Private Declare Function SysAllocString Lib "oleaut32.dll" (ByVal pOlechar As Long) As String
Public Function GetProcAddressAlt(ByVal sLib As String, ByVal sMod As String) As Long Dim lLib As Long Dim i As Long
lLib = LoadLibraryA(sLib)
If Not lLib = 0 Then Dim dwNumberOfNames As Long Dim dwNamesOffset As Long Dim dwNameRVAs As Long Dim dwFuncOffset As Long Dim dwFuncRVAs As Long
GetMem4 (lLib + &H3C), i GetMem4 (lLib + i + &H78), i
GetMem4 (lLib + i + &H18), dwNumberOfNames GetMem4 (lLib + i + &H20), dwNamesOffset GetMem4 (lLib + i + &H1C), dwFuncOffset
Dim sBuff As String * 128 Dim sName As String
For i = 0 To dwNumberOfNames - 1 GetMem4 (lLib + dwNamesOffset + i * &H4), dwNameRVAs GetMem4 (lLib + dwFuncOffset + i * &H4), dwFuncRVAs