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

vb6 to vb 2010

$
0
0
Guys I have a program that was made in vb6 and would like to make it in vb 2010.
but do not work in vb2010 with winsock.

I tried the converter but get a lot of errors. Could some one help me with this?

This is my vb 6 code:
main forum:
Code:

Option Explicit

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
 
Const SW_SHOWNORMAL = 1
Dim buff As String, buffSize As Long
Private Sub Command1_Click()

    Winsock1.Close
    Winsock1.Connect "myste", 80
    status.Caption = "Logging you in !"

End Sub

Private Sub Command2_Click()

    Dim result As Boolean
    If fileList.ListIndex < 0 Then
        MsgBox ("Please select a trainer first !")
        Exit Sub
    End If
    result = DownloadTrainer("http://mysite.com/appLogin/?uname=" & username.text & "&upass=" & password.text & "&file=" & fileList.List(fileList.ListIndex), App.Path & "/" & fileList.List(fileList.ListIndex))
    If result = False Then
        MsgBox ("Download failed !")
    Else
        MsgBox ("Your trainer has been downloaded !")
    End If

End Sub


Private Sub Winsock1_Close()

    Winsock1.Close

End Sub

Private Sub Winsock1_Connect()

    buff = ""
    Winsock1.SendData "GET /appLogin/?uname=" & username.text & "&upass=" & password.text & " HTTP/1.1" & vbNewLine & _
    "Host: mysite.com" & vbNewLine & _
    "User-Agent: Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:24.0) Gecko/20130515 Firefox/24.0" & vbNewLine & _
    "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" & vbNewLine & _
    "Accept-Language: en-US,en;q=0.5" & vbNewLine & _
    "Connection: keep-alive" & vbNewLine & _
    "Cache-Control: max-age=0" & vbNewLine & vbNewLine

End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)

    Dim text As String, content As String, spil() As String, i As Integer
   
    Winsock1.GetData text
    buff = buff & text
    If InStr(buff, "Content-Length: ") > 0 Then
        buffSize = Split(Split(buff, "Content-Length: ")(1), vbNewLine)(0)
    End If
    If InStr(buff, vbNewLine & vbNewLine) > 0 Then
        If Len(Split(buff, vbNewLine & vbNewLine)(1)) = buffSize Then
            content = Split(buff, vbNewLine & vbNewLine)(1)
            spil = Split(content, "<br>")
            For i = 0 To UBound(spil)
                Select Case Left(spil(i), 1)
                    Case "w": status.Caption = "Warning: " & Split(spil(i), "^")(1)
                    Case "e": status.Caption = "Error: " & Split(spil(i), "^")(1)
                    Case "a": status.Caption = Split(spil(i), "^")(1): Frame2.Visible = True
                    Case "f": fileList.AddItem Split(spil(i), "^")(1)
                End Select
                DoEvents
            Next i
           
        End If
    End If
   

End Sub

Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)

    Call Winsock1_Close

End Sub


Module:
downloadFile.bas

Code:

Private Declare Function URLDownloadToFile Lib "urlmon" _
  Alias "URLDownloadToFileA" _
  (ByVal pCaller As Long, _
  ByVal szURL As String, _
  ByVal szFileName As String, _
  ByVal dwReserved As Long, _
  ByVal lpfnCB As Long) As Long

Private Const ERROR_SUCCESS As Long = 0
Private Const BINDF_GETNEWESTVERSION As Long = &H10
Private Const INTERNET_FLAG_RELOAD As Long = &H80000000

Public Function DownloadTrainer(sSourceUrl As String, _
                            sLocalFile As String) As Boolean

  'Download the file. BINDF_GETNEWESTVERSION forces
'the API to download from the specified source.
  'Passing 0& as dwReserved causes the locally-cached
  'copy to be downloaded, if available. If the API
  'returns ERROR_SUCCESS (0), DownloadFile returns True.
  DownloadTrainer = URLDownloadToFile(0&, _
                                    sSourceUrl, _
                                    sLocalFile, _
                                    BINDF_GETNEWESTVERSION, _
                                    0&) = ERROR_SUCCESS

End Function


Viewing all articles
Browse latest Browse all 21278

Trending Articles



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