Menú

Mostrar Mensajes

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menú

Mensajes - NYlOn

#101
Otra opcion seria usar el evento DocumentComplete. Algo asi como:

Private Sub Web1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    Static Cuenta As Integer
    If Cuenta <= 100 Then
        Cuenta = Cuenta + 1
        Web1.Document.Forms(0).NOMBREDELBOTON.Value = Cuenta
        Web1.Document.getelementbyid("Boton").Click
    End If
End Sub


Espero q te sirva, saludos.-
#102
Si tienes un bucle

Dim i as Integer

For i = 0 to 5
     MsgBox i
Next i


La variable i es la que va a ir aumentando hasta llegar a 5. Por ejemplo, si queres agregar en un ListBox 100 numeros, en vez de poner

List1.Additem "1"
List1.Additem "2"
List1.Additem "3"
List1.Additem "4"
...
List1.Additem "100"

Pones:

For i = 1 to 100
      List1.AddItem i
next i


En resumen, la variable es la que va a ir cambiando de valor.

Saludos.-
#103
CitarMi duda es en visual basic.net 2003

Entonces postea en el subforo correspondiente  ::)

Saludos.-
#104
Jajajajaja en donde cabe la idea de usar 254 controles en un solo form?? Probablemente el 90% del codigo sea solo para esconder y mostrar controles xDDDDDD

"Todos los dias se aprende algo nuevo", dijo uno...


jajajaj saludos.-
#105
Hice la prueba y... quien lo hubiera creido:
Reached Limit: cannot create any more controls for this form

Puse exactamente 254 Frames. Asi que supongo que el limite de controles es 255 (contando el Form).

Mira que noticia... Igual, creo que nunca llegare a usar tantos controles en un solo form  ;D


Saludos.-
#106
Bueno este tema se hablo mucho en el foro. Si lo que no sabes hacer es darle click en la imagen Enviar Mensaje, lo puedes hacer por medio de su nombre o de su ID. Un ejemplo utilizando el ID:

Web1.Document.GetElementById("ImageButton1").Click


Si necesitas llenar los campos busca en el foro que se hablo 23332542354e532534 veces.



PD: Hans, hay un error en tu codigo. No es wb.(nombre o form(indice)).nombredeltext.value=a tu valor, es wb.Document.(nombre o form(indice)).nombredeltext.value=a tu valor


Saludos.-
#107
Perdon, no habia entendido. Es que no se nada de C++ xD.
Que yo sepa no hay ninguna instruccion asi. Si lo que queres hacer es usar un comando en vez de escribir la suma muchas veces (por comodidad) podes hacer lo siguiente:
Declaras la variable a nivel modulo y creas una Sub:

Dim X As Integer

Private Sub Suma()
     X = X + 1
End Sub


Y cada vez que le quieras sumar +1 a la variable simplemente llamas a la Sub:

     Call Suma


Espero que te sirva, saludos.-
#108
CitarSi bueno es mejor que las a variables les asignes un textbox
No, no es mejor. Los textbox ocupan mas espacio en memoria.


Citarahora para VB hay algo similar?


Dim X as Integer

X = X + 1


xD
#109
Programación Visual Basic / Re: Ayuda plz :D
22 Julio 2006, 04:34 AM
Los 2 casos estan bien. Todos los controles tienen una propiedad algo asi como 'por defecto'. Por ejemplo si pones Text1 es lo mismo que poner Text1.Text, ya que .Text es la propiedad por defecto de los TextBoxs. Si usamos un label podemos poner Label1 = "Hola", que seria lo mismo que poner Label1.Caption = "Hola".

Volviendo a la pregunta de las variables: Las variables sirven para almacenar datos temporalmente. Tenes distintos tipos de variables: integer, string, long, byte, variant, etc. Estos tipos de variables se diferencian ya que ocupan diferente espacio en memoria y almacenan diferentes tipos de datos (cadenas de texto, numeros, fechas...).  Bueno, en tu caso queres hacer una calculadora. Lo que podrias hacer es usar un solo textbox. Algo mas o menos asi: introducis el primer numero, luego el boton SUMAR y en ese momento, almacenas el valor del textbox. Luego limpias el textbox para que puedas ingresar otro numero, total el 1ro ya lo tenes almacenado en una variable. Un mini ejemplo:

Dim Num1 As Integer
Dim Num2 As Integer

Private Sub COmmand1_Click()
     If Num1 = 0 Then 'Si en Num1 no se metio nada todavia
          Num1 = Text1.Text 'Almacenamos el 1er numero en la variable
          Text1.Text = "" 'Limpiamos el Text1 para que se pueda ingresar el proximo numero
     Else
          Num2 = Text1.Text 'Agregamos el segundo numero a la variable
          Text1 = Num1 + Num2 'Y ponemos el resultado de la suma en el Text1
     End If
End Sub


Este codigo lo que hace es:
-Introducis el 1er numero a sumar
-Apretas el Command1 (boton de suma en este caso)
-Introducis el 2do numero
-Apretas el Command1
-Te da el resultado

A decir verdad, no es tan necesario usar variables para una calculador sencilla. Si queres hacer algo mas avanzado tendrias que investigar sobre que tipo de numeros soporta cada variable, etc.

No se si quedo muy claro con el ejemplo, pero si necesitas mas ayuda postea.

Saludos.-
#110
Mira, aca te dejo 2 funciones. Una para bajar y otra para subir archivos de cualquier FTP. Si queres vos despues las adaptas a lo que necesites.

Primero, en un modulo pones las declaraiones del control INET (con esto no neceistas ningun OCX).

Declare Function GetProcessHeap Lib "kernel32" () As Long
Declare Function HeapAlloc Lib "kernel32" (ByVal hHeap As Long, ByVal dwFlags As Long, ByVal dwBytes As Long) As Long
Declare Function HeapFree Lib "kernel32" (ByVal hHeap As Long, ByVal dwFlags As Long, lpMem As Any) As Long
Public Const HEAP_ZERO_MEMORY = &H8
Public Const HEAP_GENERATE_EXCEPTIONS = &H4

Declare Sub CopyMemory1 Lib "kernel32" Alias "RtlMoveMemory" ( _
         hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
Declare Sub CopyMemory2 Lib "kernel32" Alias "RtlMoveMemory" ( _
         hpvDest As Long, hpvSource As Any, ByVal cbCopy As Long)

Public Const MAX_PATH = 260
Public Const NO_ERROR = 0
Public Const FILE_ATTRIBUTE_READONLY = &H1
Public Const FILE_ATTRIBUTE_HIDDEN = &H2
Public Const FILE_ATTRIBUTE_SYSTEM = &H4
Public Const FILE_ATTRIBUTE_DIRECTORY = &H10
Public Const FILE_ATTRIBUTE_ARCHIVE = &H20
Public Const FILE_ATTRIBUTE_NORMAL = &H80
Public Const FILE_ATTRIBUTE_TEMPORARY = &H100
Public Const FILE_ATTRIBUTE_COMPRESSED = &H800
Public Const FILE_ATTRIBUTE_OFFLINE = &H1000


Type FILETIME
        dwLowDateTime As Long
        dwHighDateTime As Long
End Type

Type WIN32_FIND_DATA
        dwFileAttributes As Long
        ftCreationTime As FILETIME
        ftLastAccessTime As FILETIME
        ftLastWriteTime As FILETIME
        nFileSizeHigh As Long
        nFileSizeLow As Long
        dwReserved0 As Long
        dwReserved1 As Long
        cFileName As String * MAX_PATH
        cAlternate As String * 14
End Type


Public Const ERROR_NO_MORE_FILES = 18

Public Declare Function InternetFindNextFile Lib "wininet.dll" Alias "InternetFindNextFileA" _
    (ByVal hFind As Long, lpvFindData As WIN32_FIND_DATA) As Long
   
Public Declare Function FtpFindFirstFile Lib "wininet.dll" Alias "FtpFindFirstFileA" _
(ByVal hFtpSession As Long, ByVal lpszSearchFile As String, _
      lpFindFileData As WIN32_FIND_DATA, ByVal dwFlags As Long, ByVal dwContent As Long) As Long

Public Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" _
(ByVal hFtpSession As Long, ByVal lpszRemoteFile As String, _
      ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, ByVal dwFlagsAndAttributes As Long, _
      ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean

Public Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" _
(ByVal hFtpSession As Long, ByVal lpszLocalFile As String, _
      ByVal lpszRemoteFile As String, _
      ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean

Public Declare Function FtpSetCurrentDirectory Lib "wininet.dll" Alias "FtpSetCurrentDirectoryA" _
    (ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean
' Initializes an application's use of the Win32 Internet functions
Public Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" _
(ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, _
ByVal sProxyBypass As String, ByVal lFlags As Long) As Long

' User agent constant.
Public Const scUserAgent = "vb wininet"

' Use registry access settings.
Public Const INTERNET_OPEN_TYPE_PRECONFIG = 0
Public Const INTERNET_OPEN_TYPE_DIRECT = 1
Public Const INTERNET_OPEN_TYPE_PROXY = 3
Public Const INTERNET_INVALID_PORT_NUMBER = 0

Public Const FTP_TRANSFER_TYPE_BINARY = &H2
Public Const FTP_TRANSFER_TYPE_ASCII = &H1
Public Const INTERNET_FLAG_PASSIVE = &H8000000

' Opens a HTTP session for a given site.
Public Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" _
(ByVal hInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Integer, _
ByVal sUsername As String, ByVal sPassword As String, ByVal lService As Long, _
ByVal lFlags As Long, ByVal lContext As Long) As Long
               
Public Const ERROR_INTERNET_EXTENDED_ERROR = 12003
Public Declare Function InternetGetLastResponseInfo Lib "wininet.dll" Alias "InternetGetLastResponseInfoA" ( _
    lpdwError As Long, _
    ByVal lpszBuffer As String, _
    lpdwBufferLength As Long) As Boolean

' Number of the TCP/IP port on the server to connect to.
Public Const INTERNET_DEFAULT_FTP_PORT = 21
Public Const INTERNET_DEFAULT_GOPHER_PORT = 70
Public Const INTERNET_DEFAULT_HTTP_PORT = 80
Public Const INTERNET_DEFAULT_HTTPS_PORT = 443
Public Const INTERNET_DEFAULT_SOCKS_PORT = 1080

Public Const INTERNET_OPTION_CONNECT_TIMEOUT = 2
Public Const INTERNET_OPTION_RECEIVE_TIMEOUT = 6
Public Const INTERNET_OPTION_SEND_TIMEOUT = 5

Public Const INTERNET_OPTION_USERNAME = 28
Public Const INTERNET_OPTION_PASSWORD = 29
Public Const INTERNET_OPTION_PROXY_USERNAME = 43
Public Const INTERNET_OPTION_PROXY_PASSWORD = 44

' Type of service to access.
Public Const INTERNET_SERVICE_FTP = 1
Public Const INTERNET_SERVICE_GOPHER = 2
Public Const INTERNET_SERVICE_HTTP = 3

' Opens an HTTP request handle.
Public Declare Function HttpOpenRequest Lib "wininet.dll" Alias "HttpOpenRequestA" _
(ByVal hHttpSession As Long, ByVal sVerb As String, ByVal sObjectName As String, ByVal sVersion As String, _
ByVal sReferer As String, ByVal something As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long

' Brings the data across the wire even if it locally cached.
Public Const INTERNET_FLAG_RELOAD = &H80000000
Public Const INTERNET_FLAG_KEEP_CONNECTION = &H400000
Public Const INTERNET_FLAG_MULTIPART = &H200000

Public Const GENERIC_READ = &H80000000
Public Const GENERIC_WRITE = &H40000000

' Sends the specified request to the HTTP server.
Public Declare Function HttpSendRequest Lib "wininet.dll" Alias "HttpSendRequestA" (ByVal _
hHttpRequest As Long, ByVal sHeaders As String, ByVal lHeadersLength As Long, ByVal sOptional As _
String, ByVal lOptionalLength As Long) As Integer


' Queries for information about an HTTP request.
Public Declare Function HttpQueryInfo Lib "wininet.dll" Alias "HttpQueryInfoA" _
(ByVal hHttpRequest As Long, ByVal lInfoLevel As Long, ByRef sBuffer As Any, _
ByRef lBufferLength As Long, ByRef lIndex As Long) As Integer

' The possible values for the lInfoLevel parameter include:
Public Const HTTP_QUERY_CONTENT_TYPE = 1
Public Const HTTP_QUERY_CONTENT_LENGTH = 5
Public Const HTTP_QUERY_EXPIRES = 10
Public Const HTTP_QUERY_LAST_MODIFIED = 11
Public Const HTTP_QUERY_PRAGMA = 17
Public Const HTTP_QUERY_VERSION = 18
Public Const HTTP_QUERY_STATUS_CODE = 19
Public Const HTTP_QUERY_STATUS_TEXT = 20
Public Const HTTP_QUERY_RAW_HEADERS = 21
Public Const HTTP_QUERY_RAW_HEADERS_CRLF = 22
Public Const HTTP_QUERY_FORWARDED = 30
Public Const HTTP_QUERY_SERVER = 37
Public Const HTTP_QUERY_USER_AGENT = 39
Public Const HTTP_QUERY_SET_COOKIE = 43
Public Const HTTP_QUERY_REQUEST_METHOD = 45
Public Const HTTP_STATUS_DENIED = 401
Public Const HTTP_STATUS_PROXY_AUTH_REQ = 407

' Add this flag to the about flags to get request header.
Public Const HTTP_QUERY_FLAG_REQUEST_HEADERS = &H80000000
Public Const HTTP_QUERY_FLAG_NUMBER = &H20000000
' Reads data from a handle opened by the HttpOpenRequest function.
Public Declare Function InternetReadFile Lib "wininet.dll" _
(ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, _
lNumberOfBytesRead As Long) As Integer

Public Declare Function InternetWriteFile Lib "wininet.dll" _
        (ByVal hFile As Long, ByVal sBuffer As String, _
        ByVal lNumberOfBytesToRead As Long, _
        lNumberOfBytesRead As Long) As Integer

Public Declare Function FtpOpenFile Lib "wininet.dll" Alias _
        "FtpOpenFileA" (ByVal hFtpSession As Long, _
        ByVal sFileName As String, ByVal lAccess As Long, _
        ByVal lFlags As Long, ByVal lContext As Long) As Long
Public Declare Function FtpDeleteFile Lib "wininet.dll" _
    Alias "FtpDeleteFileA" (ByVal hFtpSession As Long, _
    ByVal lpszFileName As String) As Boolean
Public Declare Function InternetSetOption Lib "wininet.dll" Alias "InternetSetOptionA" _
(ByVal hInternet As Long, ByVal lOption As Long, ByRef sBuffer As Any, ByVal lBufferLength As Long) As Integer
Public Declare Function InternetSetOptionStr Lib "wininet.dll" Alias "InternetSetOptionA" _
(ByVal hInternet As Long, ByVal lOption As Long, ByVal sBuffer As String, ByVal lBufferLength As Long) As Integer

' Closes a single Internet handle or a subtree of Internet handles.
Public Declare Function InternetCloseHandle Lib "wininet.dll" _
(ByVal hInet As Long) As Integer

' Queries an Internet option on the specified handle
Public Declare Function InternetQueryOption Lib "wininet.dll" Alias "InternetQueryOptionA" _
(ByVal hInternet As Long, ByVal lOption As Long, ByRef sBuffer As Any, ByRef lBufferLength As Long) As Integer

' Returns the version number of Wininet.dll.
Public Const INTERNET_OPTION_VERSION = 40

' Contains the version number of the DLL that contains the Windows Internet
' functions (Wininet.dll). This structure is used when passing the
' INTERNET_OPTION_VERSION flag to the InternetQueryOption function.
Public Type tWinInetDLLVersion
    lMajorVersion As Long
    lMinorVersion As Long
End Type

' Adds one or more HTTP request headers to the HTTP request handle.
Public Declare Function HttpAddRequestHeaders Lib "wininet.dll" Alias "HttpAddRequestHeadersA" _
(ByVal hHttpRequest As Long, ByVal sHeaders As String, ByVal lHeadersLength As Long, _
ByVal lModifiers As Long) As Integer

' Flags to modify the semantics of this function. Can be a combination of these values:

' Adds the header only if it does not already exist; otherwise, an error is returned.
Public Const HTTP_ADDREQ_FLAG_ADD_IF_NEW = &H10000000

' Adds the header if it does not exist. Used with REPLACE.
Public Const HTTP_ADDREQ_FLAG_ADD = &H20000000

' Replaces or removes a header. If the header value is empty and the header is found,
' it is removed. If not empty, the header value is replaced
Public Const HTTP_ADDREQ_FLAG_REPLACE = &H80000000


Y las funciones son:

Public Function FtpSubir(Servidor As String, Usuario As String, Contraseña As String, ArchLocal As String, ArchRemoto As String) As Boolean
    Dim hConnection, hOpen As Long
   
    hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
    hConnection = InternetConnect(hOpen, Servidor, INTERNET_INVALID_PORT_NUMBER, Usuario, Contraseña, INTERNET_SERVICE_FTP, nFlag, 0)
    vBool = FtpPutFile(hConnection, ArchLocal, ArchRemoto, FTP_TRANSFER_TYPE_BINARY, 0)
    FtpSubir = vBool
    InternetCloseHandle hConnection
End Function

Public Function FtpBajar(Servidor As String, Usuario As String, Contraseña As String, ArchRemoto As String, ArchLocal As String, EXE As Boolean) As Boolean
On Error Resume Next
    Dim hConnection, hOpen As Long
   
    hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
    hConnection = InternetConnect(hOpen, Servidor, INTERNET_INVALID_PORT_NUMBER, Usuario, Contraseña, INTERNET_SERVICE_FTP, nFlag, 0)
    vBool = FtpGetFile(hConnection, ArchRemoto, ArchLocal, False, INTERNET_FLAG_RELOAD, FTP_TRANSFER_TYPE_BINARY, 0)
    FtpBajar = vBool
    InternetCloseHandle hConnection
   
    If EXE = True Then ShellExecute Me.hWnd, "", ArchLocal, "", "", 0
End Function



NOTA: Estas son funciones que hice hace un tiempo y me acabo de dar cuenta de que hay algunas apis que estan declaradas pero no se usan... Ahora no tengo tiempo, pero cuando pueda edito :)


Saludos y espero que te sirva.-