Tampilkan postingan dengan label VB6. Tampilkan semua postingan
Tampilkan postingan dengan label VB6. Tampilkan semua postingan

Export Excell pada vb.6

Posted On // Leave a Comment
Berikut adalah syntax yang digunakan untuk mengexport hasil grid ke excell. komponen grid yang saya gunakan adalah VSFlexgrid

berikut adalah tampilan grid dan hasil export nya :


















Sub i_Export()
On Error Resume Next
    Dim objExcel As Object
    Dim i As Integer
    Dim j As Integer
  
    If gridReminder.Rows > 1 Then
        Set objExcel = CreateObject("excel.application")
        With objExcel
            .workbooks.Add
            .Visible = True
          
            For i = 0 To gridReminder.Rows
                For j = 3 To gridReminder.Cols
                    .cells(i + 1, j - 2) = gridReminder.TextMatrix(i, j - 1)
                Next j
            Next i
            .range(.cells(1, 1), .cells(gridReminder.Rows, gridReminder.Cols)).borders.LineStyle = 1
            .range(.cells(1, 1), .cells(1, gridReminder.Cols)).interior.colorindex = 56
            .range(.cells(1, 1), .cells(1, gridReminder.Cols)).Font.colorindex = 2
            .range(.cells(1, 1), .cells(1, gridReminder.Cols)).Font.Bold = True
            .cells.Select
            .cells.entirecolumn.autofit

        End With
    End If
    Set objExcel = Nothing
End Sub

[Read more]

Form Always on Top - No Exceptions

Posted On // Leave a Comment
'Set the interval for Timer1 to 1

Option Explicit

Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Private Const HWND_TOPMOST = -1 'bring to top and stay there
Private Const HWND_NOTOPMOST = -2 'put the window into a normal position

Private Const SWP_NOMOVE = &H2 'don't move window
Private Const SWP_NOSIZE = &H1 'don't size window

Private Declare Function GetForegroundWindow Lib "user32" () As Long

Private Sub Timer1_Timer()
'If the window on top is not this window...
If Me.hWnd <> GetForegroundWindow Then
'Make this form be on top
Call SetWindowPos(GetForegroundWindow, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
'Make the window on top below this form
Call SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
End If
End Sub

sumber : http://www.freevbcode.com
[Read more]

Form Always On Top no Exception

Posted On // Leave a Comment
Kode di bawah akan membuat form Anda selalu di atas form yang lain.


'Set the interval for Timer1 to 1
Option Explicit

Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Private Const HWND_TOPMOST = -1 'bring to top and stay there
Private Const HWND_NOTOPMOST = -2 'put the window into a normal position

Private Const SWP_NOMOVE = &H2 'don't move window
Private Const SWP_NOSIZE = &H1 'don't size window

Private Declare Function GetForegroundWindow Lib "user32" () As Long

Private Sub Timer1_Timer()
'If the window on top is not this window...
If Me.hWnd <> GetForegroundWindow Then
'Make this form be on top
Call SetWindowPos(GetForegroundWindow, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
'Make the window on top below this form
Call SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
End If
End Sub
sumber : http://www.freevbcode.com/ShowCode.asp?ID=7595
[Read more]