Visualizzazione post con etichetta VB6. Mostra tutti i post
Visualizzazione post con etichetta VB6. Mostra tutti i post

venerdì 8 maggio 2015

vb6 outlook

Public Sub componiMailOutlook(destinatari As String, destinatariCC As String, destinatariBcc As String, oggettoMail As String, fileAllegati As String)
Dim OutApp As Object
Dim OutMail As Object  'sarebbe un oggetto MailItem

  Set OutApp = CreateObject("Outlook.Application")
  OutApp.Session.Logon
  Set OutMail = OutApp.CreateItem(0)

  On Error Resume Next
  With OutMail
    .display
    .To = destinatari
    If destinatariCC <> "" Then
     .cc = destinatariCC
    End If
    If destinatariBcc <> "" Then
      .BCC = destinatariBcc
    End If
    .subject = oggettoMail
    '.htmlbody = testoMail
    If fileAllegati <> "" Then
      .Attachments.Add fileAllegati
    End If
    .Readreceiptrequested = False
  End With

  On Error GoTo 0
  Set OutMail = Nothing
  Set OutApp = Nothing

End Sub

vb6 thinderbird

Public Sub componiMailThunderBird(destinatari As String, destinatariCC As String, destinatariBcc As String, oggettoMail As String, fileAllegati As String)
Dim comandoShell
Dim pathThunderbird As String


  comandoShell = Chr(34) & pathThunderbird & Chr(34) & " -compose " & Chr(34)
  comandoShell = comandoShell & "to='" & destinatari & "',"
  comandoShell = comandoShell & "cc='" & destinatariCC & "',"
  comandoShell = comandoShell & "bcc='" & destinatariBcc & "',"
  comandoShell = comandoShell & "subject='" & oggettoMail & "'"
  If fileAllegati <> "" Then
    comandoShell = comandoShell & ",attachment='" & fileAllegati & "'"
  End If

  Shell comandoShell

End Sub

giovedì 7 maggio 2015

vb6 winrar

Private Sub cmdComprimi_Click()
Dim comando As String
Dim nomedir As String
Dim strAnno As String
Dim strMese As String
Dim S As Object


  'imposta il nome del file.Presuponendo che il periodo scelto sia un mese e quindi prende in considerazione il mede della data di inizio estrazione
  'se inevecej è un trimestre mette il primo carattere del cmbmese
  strAnno = Year(Me.TxtInizio)
  strMese = Format(Month(Me.TxtInizio), "00")
  If Me.CmbTipoPeriodo = "trim" Then
    strMese = "trim" & Left(Me.CmbMese, 1)
  End If
  nomedir = App.Path & "\report" & strAnno & "\" & strAnno & "_" & strMese & "\"

  comando = "c:\Programmi\WinRAR\rar.exe a " & """" & nomedir & strAnno & "_" & strMese & ".rar"" -p" & Format(Me.TxtInizio, "mmmmYYYY") & " -ep " & Chr(34) & nomedir & "*" & Chr(34)
  Shell comando

  Set S = CreateObject("Shell.Application")
  S.ShellExecute (nomedir)
  Open nomedir & "pw.txt" For Output As #1
  Print #1, Format(Me.TxtInizio, "mmmmYYYY")
  Close (1)
End Sub

giovedì 16 aprile 2015

vb6 aprire un file excel esistente (nuovo o esistente)


Option Explicit

'variabili per excel
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object
Dim nomefile As String



Private Sub cmdApriFileExcel_Click()

  'inizializza nomefile
  nomefile = App.Path & "xxxxx_.xls"
  'Start a new workbook in Excel
  Set oExcel = CreateObject("Excel.Application")
  Set oBook = oExcel.Workbooks.Open(nomefile)
 
End Sub

Private Sub cmdCreaFileExcel_Click()
  'Start a new workbook in Excel
  Set oExcel = CreateObject("Excel.Application")
  Set oBook = oExcel.Workbooks.Add

End Sub

connessione access 2000

Tra i riferimenti inserire microsoft DAO 3.6




Option Explicit

dim dbArchivio As Database
dim rsTabellA As DAO.Recordset

Dim nomedatabase As String
Dim nometabella As String


Private Sub Form_Load()

  nomedatabase = "aaaaaaaa.mdb"
   nometabella = "bbbbbb"

  Set dbArchivio = DBEngine(0).OpenDatabase(nomedatabase)
  Set rsTabellA = dbArchivio.OpenRecordset(nometabella)

End Sub

giovedì 8 gennaio 2015

exportGridToExcel


Public Sub exportGridToExcel(nomegriglia As MSFlexGrid)

Dim oExcel  As Object
Dim oBook As Object

Dim i As Integer
Dim j As Integer

  'Start a new workbook in Excel
  Set oExcel = CreateObject("Excel.Application")
  Set oBook = oExcel.Workbooks.Add
  oExcel.Visible = True
  'riporta la griglia in excel
  For i = 0 To nomegriglia.Rows - 1
    For j = 0 To nomegriglia.Cols - 1
      oExcel.cells(i + 1, j + 1).Value = nomegriglia.TextMatrix(i, j)
    Next
  Next
 
  MsgBox "salvataggio su excel terminato"
 
End Sub

venerdì 11 aprile 2014

DRAG-DROP SU TREEVIEW

Private Sub TreeView1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
   If Button = vbLeftButton Then ' Signal a Drag operation.
      Draging = True ' Set the flag to true.
      ' Set the drag icon with the CreateDragImage method.
     
      TreeView1.Drag vbBeginDrag ' Drag operation.
   End If
End Sub

Private Sub TreeView1_DragOver(Source As Control, x As Single, y As Single, State As Integer)
   If Draging = True Then
      ' Set DropHighlight to the mouse's coordinates.
      Set TreeView1.DropHighlight = TreeView1.HitTest(x, y)
   End If
End Sub


Private Sub gridMail_DragDrop(Source As Control, x As Single, y As Single)
  Set nodoScelto = TreeView1.SelectedItem
  'se il nodo è livello 3 significa che è un fornitore e quindi lo inserisce subito in lista
  If livelloNodo(nodoScelto) = 3 Then
    aggiungiInGridMail nodoScelto.Text
  End If
 
End Sub





lunedì 10 marzo 2014

Inviare una mail outlook con VB6

Private Sub inviaMail()
Dim OutApp As Object
Dim OutMail As Object
Dim nomefiledaallegare As String
Dim testoMail As String
Dim FIRME As String
Dim SIGNATURE As String

  Set OutApp = CreateObject("Outlook.Application")
  OutApp.Session.Logon
  Set OutMail = OutApp.CreateItem(0)


FIRME = "C:\Documents and Settings\XXXXXXXXXXXXXXXXXXX\Dati applicazioni\Microsoft\Firme elettroniche\xxxxxx.htm"
If Dir(FIRME) <> "" Then
SIGNATURE = GetBoiler(FIRME)
Else
SIGNATURE = ""
End If
   
  testoMail = "<html><head></head><body>"
  testoMail = testoMail & "Ciao<br>"
  testoMail = testoMail & "Prova invio mail da outlook con VB6."
  testoMail = testoMail & "</body></html>" & " " & SIGNATURE

   
  On Error Resume Next
  With OutMail
    .display
    .To = "destinatario@itn.it"
    .CC = ""
    .BCC = ""
    .Subject = "Prova invio mail da outlook con VB6."
    .HTMLbody = testoMail
    .Attachments.Add nomeFile
    '.send
    .Readreceiptrequested = False
  End With
  On Error GoTo 0
  Set OutMail = Nothing
  Set OutApp = Nothing
 
End Sub

Private Sub Command1_Click()
inviaMail
End Sub


Function GetBoiler(ByVal sFile As String) As String
    Dim fso As Object
    Dim ts As Object
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
    GetBoiler = ts.readall
    ts.Close
End Function

lunedì 3 febbraio 2014

[VB6] riportare su una lista le sottocartelle di una directoyry

prerequisiti

bisogna attivare tra i riferimenti "Micrisoft scritpting runtime"

codice

Private Sub listaSubDir(ByVal dirIniziale As String, ByVal listaDestinazione As ListBox, ByVal togliInizio As Integer)
Dim fso As New FileSystemObject
Dim Directory As Folder
Dim SubDirs As Folder

  Set Directory = fso.GetFolder(dirIniziale)
  
  For Each SubDirs In Directory.SubFolders
    listaDestinazione.AddItem Mid(SubDirs.Path, togliInizio + 1), 0
    listaSubDir dirIniziale & "\" & SubDirs.Name, listaDestinazione, togliInizio
  Next

End Sub

lunedì 9 dicembre 2013

[VB6] conoscere MAC address


Private Sub Command1_Click()
'elenco indirizzi IP

Dim objWMIService, colNetAdapters, objNetAdapter
    
  Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
  Set colNetAdapters = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration " & "where IPEnabled=TRUE")

  For Each objNetAdapter In colNetAdapters
    Text1(0).Text = objNetAdapter.Caption
    Text1(1).Text = objNetAdapter.MACAddress
    Text1(2).Text = Join(objNetAdapter.ipAddress, ",")
    MsgBox objNetAdapter.MACAddress

  Next


End Sub

giovedì 7 novembre 2013

aprire un file con il programma predefinito

'invece di utilizzare shell uilizzo il metodo shellexecute dell'oggetto shell.application

Dim S As Object
  Set S = CreateObject("Shell.Application")
  S.ShellExecute (nomeFilePDF)

mercoledì 30 ottobre 2013

informazioni su ADO in ASP e VB6



Tipi che si possono assegnare ad ADO

adCmdUnspecified
-1
Does not specify the command type argument.
adCmdText
1
Evaluates CommandText as a textual definition of a command or stored procedure call.
adCmdTable
2
Evaluates CommandText as a table name whose columns are all returned by an internally generated SQL query.
adCmdStoredProc
4
Evaluates CommandText as a stored procedure name.
adCmdUnknown
8
Default. Indicates that the type of command in the CommandText property is not known.
adCmdFile
256
Evaluates CommandText as the file name of a persistently stored Recordset. Used with Recordset.Open or Requery only.
adCmdTableDirect
512
Evaluates CommandText as a table name whose columns are all returned. Used with Recordset.Open or Requery only. To use the Seek method, the Recordset must be opened with adCmdTableDirect. This value cannot be combined with the ExecuteOptionEnum value adAsyncExecute.

Codice del tipo di dato di  una tabella in sql server, alla quale ci si è connessi con ADO
Constant
Value
Description
adEmpty
0
No value
adSmallInt
2
A 2-byte signed integer.
adInteger
3
A 4-byte signed integer.
adSingle
4
A single-precision floating-point value.
adDouble
5
A double-precision floating-point value.
adCurrency
6
A currency value
adDate
7
The number of days since December 30, 1899 + the fraction of a day.
adBSTR
8
A null-terminated character string.
adIDispatch
9
A pointer to an IDispatch interface on a COM object.Note: Currently not supported by ADO.
adError
10
A 32-bit error code
adBoolean
11
A boolean value.
adVariant
12
An Automation Variant. Note: Currently not supported by ADO.
adIUnknown
13
A pointer to an IUnknown interface on a COM object. Note:Currently not supported by ADO.
adDecimal
14
An exact numeric value with a fixed precision and scale.
adTinyInt
16
A 1-byte signed integer.
adUnsignedTinyInt
17
A 1-byte unsigned integer.
adUnsignedSmallInt
18
A 2-byte unsigned integer.
adUnsignedInt
19
A 4-byte unsigned integer.
adBigInt
20
An 8-byte signed integer.
adUnsignedBigInt
21
An 8-byte unsigned integer.
adFileTime
64
The number of 100-nanosecond intervals since January 1,1601
adGUID
72
A globally unique identifier (GUID)
adBinary
128
A binary value.
adChar
129
A string value.
adWChar
130
A null-terminated Unicode character string.
adNumeric
131
An exact numeric value with a fixed precision and scale.
adUserDefined
132
A user-defined variable.
adDBDate
133
A date value (yyyymmdd).
adDBTime
134
A time value (hhmmss).
adDBTimeStamp
135
A date/time stamp (yyyymmddhhmmss plus a fraction in billionths).
adChapter
136
A 4-byte chapter value that identifies rows in a child rowset
adPropVariant
138
An Automation PROPVARIANT.
adVarNumeric
139
A numeric value (Parameter object only).
adVarChar
200
A string value (Parameter object only).
adLongVarChar
201
A long string value.
adVarWChar
202
A null-terminated Unicode character string.
adLongVarWChar
203
A long null-terminated Unicode string value.
adVarBinary
204
A binary value (Parameter object only).
adLongVarBinary
205
A long binary value.
AdArray
0x2000
A flag value combined with another data type constant. Indicates an array of that other data type.