Get User Server Name

Posted in Source Code with tags on August 19, 2008 by programmervb

‘Task: How to get user server name [Computer name] when he login on network.

‘Declarations
Private Declare Function GetComputerName Lib “kernel32″ Alias “GetComputerNameA” (ByVal lpBuffer As String, nSize As Long) As Long

‘Code:
Private Sub Form_Load()
Dim dl,cnt As Long
Dim s As String
cnt = 200
s = Space$(cnt)
dl = Len(s)
Call GetComputerName(s, dl)
Text1.Text = Left$(s, dl)
End Sub

Make Transparant Form

Posted in Source Code with tags on August 19, 2008 by programmervb

‘Task: Make a form transparent

‘Declarations
Public Const GWL_EXSTYLE = (-20)
Public Const WS_EX_TRANSPARENT = &H20&
Public Const SWP_FRAMECHANGED = &H20
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const SWP_SHOWME = SWP_FRAMECHANGED Or _
SWP_NOMOVE Or SWP_NOSIZE
Public Const HWND_NOTOPMOST = -2

Declare Function SetWindowLong Lib “user32″ Alias “SetWindowLongA” (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

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

‘Code:
SetWindowLong Me.hwnd, GWL_EXSTYLE, WS_EX_TRANSPARENT
SetWindowPos Me.hwnd, HWND_NOTOPMOST, 0&, 0&, 0&, 0&, SWP_SHOWME

Otomation Excel

Posted in Source Code with tags on August 16, 2008 by programmervb

Dim strFile as string

strFile=App.Path & “\Text.xls”

Dim oExcel as new Excel.Application

oExcel.Workbooks.Open strfile

oExcel.Visible=True

oExcel.Quit

Set.oExcel=Nothing

Asisten Office

Posted in Source Code with tags on August 16, 2008 by programmervb

Private sub cmd_click()

Dim intPil as integer

Dim oWord as word.application

Set oWord=New Word.Application

With oWord.Assistant.NewBalloon

.BalloonType=msBalloonTypeButtons

.Heading=”Your Topic You Want”

.Text=”Choose Your Topic”

.Labels(1).Text=”First Topic…”

.Labels(2).Text=”Second Topic…”

.Animation=msoAnimationAppear

.Button=msoButtonSetOkCancel

.Mode=msoModeModal

intPil=.Show

End With

Select Case intPil

Case 1

msgbox(”You Choosen First Topic”)

Case 2

msgbox(”You Choosen Second Topic”)

End Select

oWord.Quit

Set oWord=Nothing

End Sub \