Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

kod za visual basic

[es] :: Visual Basic 6 :: kod za visual basic

[ Pregleda: 3339 | Odgovora: 4 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

pr0gramer
nezaposlen

Član broj: 163931
Poruke: 66
*.adsl.net.t-com.hr.



Profil

icon kod za visual basic23.11.2007. u 20:53 - pre 199 meseci
Ovako, radim jedan program u visual basic-u 6, I treba mi kod koji radi ovo, otvori npr. C:\Program Files\xxx\nekifajl.txt I sadržaj toga fajla pošalje na mail ili na moj ftp

Hvala
 
Odgovor na temu

Aleksandar Vasic
Web Administrator, Uspon d.o.o
Čačak

Član broj: 91692
Poruke: 1226
*.dynamic.sbb.co.yu.

Sajt: www.vasictech.net


+1 Profil

icon Re: kod za visual basic23.11.2007. u 21:50 - pre 199 meseci
sadrzaj fajla otvaras ovako

Code:
Private Sub Command1_Click()
Dim a As String
Open "C:\Program Files\xxx\nekifajl.txt" For Input As #1
Input #1, a
Text1.Text = a
End Sub


e sad za slanje koristi MAPI,tu ti ne mogu pomoci,ali naci ce se neko ;)
 
Odgovor na temu

pr0gramer
nezaposlen

Član broj: 163931
Poruke: 66
*.adsl.net.t-com.hr.



Profil

icon Re: kod za visual basic07.12.2007. u 16:00 - pre 199 meseci
nek neko kaze ako zna... vazno mi je to
 
Odgovor na temu

Eurora3D Team
Nebojsa - Programer & Vodja tima
Beograd

Član broj: 120376
Poruke: 900
91.148.114.*



+7 Profil

icon Re: kod za visual basic07.12.2007. u 21:27 - pre 199 meseci

Ovaj kod ispod salje podatke na FTP server
Za citanje fajla upotrebi funkciju koju ti je dao @The_End_is_close
Na formu stavi jedan TextBox Text1 (za unos teksta koji ce biti poslat) i jedno CommandButton Command1.
Prekopiraj kod u kod sekciju forme i ispravi parametre za tvoj FTP server u Command1_Click subrutini.
Pozdrav
Code:

'(c) Eurora3D 2007
Const FTP_TRANSFER_TYPE_UNKNOWN As Long = &H0
Const FTP_TRANSFER_TYPE_ASCII As Long = &H1
Const FTP_TRANSFER_TYPE_BINARY  As Long = &H2
Const INTERNET_FLAG_RAW_DATA = &H40000000
Const INTERNET_FLAG_EXISTING_CONNECT = &H20000000
Const INTERNET_OPEN_TYPE_DIRECT = 1
Const INTERNET_FLAG_NO_CACHE_WRITE = &H4000000
Const INTERNET_SERVICE_FTP = 1
Const GENERIC_WRITE = &H40000000
Private 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
Private Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal pub_lngInternetSession 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
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer
Private Declare Function FtpOpenFile Lib "wininet.dll" Alias "FtpOpenFileA" (ByVal hFtpSession As Long, ByVal lpszFileName As String, ByVal fdwAccess As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
Private Declare Function InternetWriteFile Lib "wininet.dll" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToWrite As Long, dwNumberOfBytesWritten As Long) As Integer

Public Function UploadToFTP(WebSite As String, FTPServer As String, UserName As String, Password As String, FileName As String, Data As String) As Boolean
On Error GoTo err
Dim Service As Long, hFile As Long, nRet As Long
Dim Adresa As String, ID As String, Pass As String, Port As Integer
Adresa = FTPServer
ID = UserName
Pass = Password
Port = 21
Transfer = FTP_TRANSFER_TYPE_BINARY
Service = INTERNET_FLAG_EXISTING_CONNECT
'conn
session = InternetOpen(WebSite, INTERNET_OPEN_TYPE_DIRECT, "", "", INTERNET_FLAG_NO_CACHE_WRITE)
If session <> 0 Then
    server = InternetConnect(session, Adresa, Port, ID, Pass, INTERNET_SERVICE_FTP, Service, &H0)
    If server = 0 Then
     UploadToFTP = False
     Exit Function
    End If
Else
    InternetCloseHandle session
     UploadToFTP = False
     Exit Function
End If
'file transfer
hFile = FtpOpenFile(server, FileName, GENERIC_WRITE, FTP_TRANSFER_TYPE_BINARY, 0)
If hFile = 0 Then
   InternetCloseHandle server
   InternetCloseHandle session
   UploadToFTP = False
   Exit Function
End If
If InternetWriteFile(hFile, Data, Len(Data), nRet) = 0 Then
    InternetCloseHandle server
    InternetCloseHandle session
    UploadToFTP = False
    Exit Function
End If
'
InternetCloseHandle hFile
InternetCloseHandle server
InternetCloseHandle session

UploadToFTP = True
Exit Function
err:
UploadToFTP = False
Debug.Print err.Description
End Function

'KORISCENJE FUNKCIJE UploadToFTP
'Prvi parametar - http adresa sajta, sa ili bez http:// na pocetku, Ako nemate sajt stavite adresu FTP servera ovde
'Drugi parametar - adresa ftp servera sa ili bez ftp:// na pocetku
'Treci parametar - FTP UserName
'Cetvrti parametar - FTP Password
'Peti parametar - puna putanja do fajla uljucuci i root folder i / na pocetku i fajl ekstenziju na kraju, sve posle ftp://myserver.com
'Root folder je obicno www, ali moze da bude i drugacije nazvan
'Sesti parametar - Podatci fajla u String bufferu

Private Sub Command1_Click()
'Koriscenje, naravno ovi parametri su pogesni
'Peti parametar je sadrzaj text boxa ali moze da bude bilo sta (npr fajl ucitan sa HD-a u String buffer)
Dim ret As Boolean
ret = UploadToFTP("http://www.eurora3d.com", "ftp://ftp.eurora3d.com", "UserNeme", "PassWord", "/www/myfiles/testfile.txt", Text1.Text)
'ili
'ret = UploadToFTP("ftp://ftp.eurora3d.com", "ftp://ftp.eurora3d.com", "UserNeme", "PassWord", "/www/myfiles/testfile.txt", Text1.Text)
End Sub

 
Odgovor na temu

miki987

Član broj: 208123
Poruke: 511
93.86.144.*



+5 Profil

icon Re: kod za visual basic19.07.2009. u 21:10 - pre 179 meseci
Jel neko proverio ovaj kod za ftp
Ako radi koliko je pouzdan :D
 
Odgovor na temu

[es] :: Visual Basic 6 :: kod za visual basic

[ Pregleda: 3339 | Odgovora: 4 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.