Visual Basic Source Code

August 20, 2017 | Author: Ini Uminya ILma | Category: N/A
Share Embed Donate


Short Description

source code untuk visual basic...

Description

august 1, 2008 Check For a File Public Function FileExist(asPath as string) as Boolean If UCase(Dir(asPath))=Ucase(trimPath(asPath)) then FileExist=true Else FileExist=False End If End Function Public Function TrimPath(ByVal asPath as string) as string if Len(asPath)=0 then Exit Function Dim x as integer Do x=Instr(asPath, \ ) if x=0 then Exit Do asPath=Right(asPath,Len(asPath)-x) Loop TrimPath=asPath End Function Private sub command1_Click() if fileExist(Text1.text) then Label1= YES else Label1= NO End if End Sub Private sub form_Load() End sub Posted by Administrator in 08:58:16 | Permalink | Comments Off Tuesday, July 1, 2008 Low and Upper Case add 2 command buttons and 1 text Private Sub Command1_Click() Text1.Text = CapFirst$(Text1.Text) End Sub Private Sub Command2_Click() Text1.Text = LCase$(Text1.Text) End Sub add 1 module Declare Function CapFirst$ Lib

CAPFIRST.DLL

Alias

CAPFIRST (ByVal St$)

Posted by Administrator in 07:11:50 | Permalink | Comments Off Show Your IP Address Add Microsoft Winsock Control 6.0 component Insert 1 Textbox Insert 2 Command Buttons Rename Caption as Display and Clear

Private Sub Command1_Click() If Text1.Text = Then Command1.Enabled = False Text1.Text = Winsock1.LocalIP Else Command1.Enabled = True End If End Sub Private Sub Command2_Click() Text1.Text = If Text1.Text = Then Command1.Enabled = True Else Command1.Enabled = False End If End Sub Private Sub Form_Load() Text1.Text = If Text1.Text = Then Command1.Enabled = False Else Command1.Enabled = True End If Text1.Text = Winsock1.LocalIP End Sub Posted by Administrator in 07:10:59 | Permalink | Comments (2) Saturday, May 17, 2008 Permutasi Option Explicit Dim id As Integer Dim N As Integer Dim perm() As Integer Function Engine(i As Integer) Dim t As Integer Dim j As Integer id = id + 1 perm(i) = id If (id = N) Then stampaj For j = 1 To N If (perm(j) = 0) Then Engine (j) End If DoEvents Next j id = id 1 perm(i) = 0 End Function Private Sub cmdClear_Click() List1.Clear End Sub Private Sub cmdGen_Click() If Val(txtLength.Text) > Len(txtChar.Text) Then

MsgBox Jumlah Permutasi Salah Exit Sub End If If Len(txtChar.Text) = 0 Or (Val(txtLength.Text) = 0) Then Exit Sub Dim i As Integer N = Val(txtLength.Text) ReDim perm(N) For i = 1 To N perm(i) = 0 Next i If ChSave.Value = 1 Then MsgBox Disimpan pada hasil.txt Open App.Path + \hasil.txt For Output As #1 End If Engine 0 If ChSave.Value = 1 Then Close #1 End Sub Sub Form_Load() On Error Resume Next id = -1 End Sub Sub stampaj() Dim i As Integer Dim result As String result = For i = 1 To N result = result & CStr(Mid$(txtChar.Text, perm(i), 1)) Next i List1.AddItem result If ChSave.Value = 1 Then Print #1, result End Sub Posted by Administrator in 05:05:49 | Permalink | Comments (5) Enkripsi Searah Public Function Hash(ByVal text As String) As String a = 1 For i = 1 To Len(text) a = Sqr(a * i * Asc(Mid(text, i, 1))) Numeric Hash Next i Rnd (-1) Randomize a seed PRNG For i = 1 To 16 Hash = Hash & Chr(Int(Rnd * 256)) Next i End Function Private Sub Form_Load() MsgBox Hash( EmZ-2509?) Yang dihasilkan: ° r?¾ ©??AX*¤W End End Sub Posted by Administrator in 04:58:18 | Permalink | Comments (1) »

Enkripsi Function EncDec(inData As Variant, Optional inPW As Variant = On Error Resume Next Dim arrSBox(0 To 255) As Integer Dim arrPW(0 To 255) As Integer Dim Bi As Integer, Bj As Integer Dim mKey As Integer Dim i As Integer, j As Integer Dim x As Integer, y As Integer Dim mCode As Byte, mCodeSeries As Variant EncDec = If Trim(inData) = Exit Function End If

Then

If inPW Then j = 1 For i = 0 To 255 arrPW(i) = Asc(Mid$(inPW, j, 1)) j = j + 1 If j > Len(inPW) Then j = 1 End If Next i Else For i = 0 To 255 arrPW(i) = 0 Next i End If For i = 0 To 255 arrSBox(i) = i Next i j = 0 For i = 0 To 255 j = (arrSBox(i) + arrPW(i)) Mod 256 x = arrSBox(i) arrSBox(i) = arrSBox(j) arrSBox(j) = x Next i mCodeSeries = Bi = 0: Bj = 0 For i = 1 To Len(inData) Bi = (Bi + 1) Mod 256 Bj = (Bj + arrSBox(Bi)) Mod 256 Tukar x = arrSBox(Bi) arrSBox(Bi) = arrSBox(Bj) arrSBox(Bj) = x siapkan kunci untuk XOR mKey = arrSBox((arrSBox(Bi) + arrSBox(Bj)) Mod 256) gunakan operasi XOR mCode = Asc(Mid$(inData, i, 1)) Xor mKey mCodeSeries = mCodeSeries & Chr(mCode)

) As Variant

Next i EncDec = mCodeSeries End Function Private Sub Form_Load() Dim Encrypt As String, Decrypt As String Encrypt = EncDec( admin , win ) Decrypt = EncDec( D`> , win ) MsgBox Hasil enkripsi : & Encrypt & _ vbCrLf & Hasil dekripsi : & Decrypt End End Sub Posted by Administrator in 04:55:41 | Permalink | Comments Off Wednesday, May 14, 2008 Menu Pop Up Option Explicit Private Declare Function SendMessage Lib user32? Alias _ SendMessageA (ByVal hwnd As Long, ByVal wMsg As Long, _ ByVal wParam As Long, lParam As Any) As Long Private Const LB_GETITEMRECT = &H198 Private Const LB_ERR = (-1) Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Public Function GetRClickedItem(MyList As Control, _ X As Single, Y As Single) As Long PURPOSE: Determine which item was right clicked in a list box, from the list_box s mouse down event. YOU MUST CALL THIS FROM THE MOUSEDOWN EVENT, PASSING THE X AND Y VALUES FROM THAT EVENT TO THIS FUNCTION MYLIST: ListBox Control X, Y: X and Y position from MyList_MouseDown RETURNS: ListIndex of selected item, or -1 if a) There is no selected item, or b) an error occurs. Dim Dim Dim Dim

clickX As Long, clickY As Long lRet As Long CurRect As RECT l As Long

Control must be a listbox If Not TypeOf MyList Is ListBox Then GetRClickedItem = LB_ERR Exit Function End If get x and y in pixels clickX = X Screen.TwipsPerPixelX

clickY = Y Screen.TwipsPerPixelY Check all items in the list to see if it was clicked on For l = 0 To MyList.ListCount 1 get current selection as rectangle lRet = SendMessage(MyList.hwnd, LB_GETITEMRECT, l, CurRect) If the position of the click is in the this list item then that s our Item If (clickX >= CurRect.Left) And (clickX = CurRect.Top) And _ (clickY 0 Then rcd (strDirectory) pData.cFileName = String(MAX_PATH, 0) hFind = FtpFindFirstFile(hConnection, *.* , pData, 0, 0) nLastError = Err.LastDllError If hFind = 0 Then If (nLastError = ERROR_NO_MORE_FILES) Then MsgBox This directory is empty! Else ErrorOut nLastError, FtpFindFirstFile End If

Exit Sub End If dError = NO_ERROR Dim bRet As Boolean Dim strItemName As String EnumItemAttributeBag.Add pData.dwFileAttributes strItemName = Left(pData.cFileName, InStr(1, pData.cFileName, String(1, 0), vbBinaryCompare) 1) EnumItemNameBag.Add strItemName Do pData.cFileName = String(MAX_PATH, 0) bRet = InternetFindNextFile(hFind, pData) If Not bRet Then dError = Err.LastDllError If dError = ERROR_NO_MORE_FILES Then Exit Do Else ErrorOut dError, InternetFindNextFile InternetCloseHandle (hFind) Exit Sub End If Else EnumItemAttributeBag.Add pData.dwFileAttributes strItemName = Left(pData.cFileName, InStr(1, pData.cFileName, String (1, 0), vbBinaryCompare) 1) EnumItemNameBag.Add strItemName End If Loop InternetCloseHandle (hFind) End Sub Private Sub optAscii_Click() dwType = FTP_TRANSFER_TYPE_ASCII End Sub Private Sub optBin_Click() dwType = FTP_TRANSFER_TYPE_BINARY End Sub Private Sub TreeView1_DblClick() Dim nodX As Node Set nodX = TreeView1.SelectedItem If Not bActiveSession Then MsgBox No in session! Exit Sub End If If nodX Is Nothing Then MsgBox no Selection to enumerate End If If nodX.Image = closed Then nodX.Image = open FtpEnumDirectory (nodX.Text) FillTreeViewControl (nodX.Text) Else If nodX.Image = open Then nodX.Image = closed Dim nodChild As Node, nodNextChild As Node

Set nodChild = nodX.Child Do Set nodNextChild = nodChild.Next TreeView1.Nodes.Remove nodChild.Index If nodNextChild Is Nothing Then Exit Do Set nodChild = nodNextChild Loop End If End If End Sub Posted by Administrator in 07:28:56 | Permalink | Comments Off Ping Network dgn VB Option Explicit Const Const Const Const

SYNCHRONIZE = &H100000 INFINITE = &HFFFF WAIT_OBJECT_0 = 0 WAIT_TIMEOUT = &H102

Dim stopflag As Boolean Dim errorflag As Boolean Dim mindelay As Integer Dim maxdelay As Integer Dim totaldelay As Long Dim avgdelay As Integer Dim lcount As Long Dim pingMessage(26) As String Dim ctrl Private Declare Function SendMessage Lib User32? Alias SendMessageA (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Declare Function OpenProcess Lib kernel32? (ByVal dwDesiredAccess As Long , ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Private Declare Function WaitForSingleObject Lib kernel32? (ByVal hHandle As Long , ByVal dwMilliseconds As Long) As Long Private Declare Function CloseHandle Lib kernel32? (ByVal hObject As Long) As Lon g Private Sub cmdClear_Click() Open C:\log.txt For Output As #1 Close #1 txtoutput.Text = txtpinglog.Text = End Sub Private Sub chklog_Click() End Sub Private Sub cmdExit_Click() Unload Me End End Sub Private Sub cmdlog_Click() Load frmlog frmlog.Show 1

End Sub Private Sub cmdPing_Click() DoEvents If cmdPing.Caption = Ping Then lblstatus.Caption = Pinging txtIP.Locked = True cmdPing.BackColor = &HFF& cmdlog.Enabled = False cmdPing.Caption = Stop stopflag = False Else stopflag = True cmdPing.Caption = Ping txtIP.Locked = False cmdPing.BackColor = &H80FF80 cmdlog.Enabled = True lblstatus.Caption = Stopped End If

& txtIP.Text &

with

& txtbuffer.Text & KB of data

While stopflag = False DoEvents Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim

t &

ShellX As String lPid As Long lHnd As Long lRet As Long VarX As String Ptime As Integer pttl As Integer pbyte As Integer i As Integer pingresult As String tmin As Integer tmax As Integer tavg As Integer

If txtIP.Text Then DoEvents ShellX = Shell( command.com /c ping -n 1 -l & txtbuffer.Text & > C:\log.txt , vbHide) lPid = ShellX If lPid 0 Then lHnd = OpenProcess(SYNCHRONIZE, 0, lPid) If lHnd 0 Then lRet = WaitForSingleObject(lHnd, INFINITE) CloseHandle (lHnd) End If

& txtIP.Tex

frmmain.MousePointer = 0 Open C:\log.txt For Input As #1 txtoutput.Text = Input(LOF(1), 1) pingresult = Trim(Mid(txtoutput.Text, InStr(1, txtoutput.Text, : ) + 1, Len(txtoutput.Text) (InStr(1, txtoutput.Text, : ) + Len(Mid(txtoutput.Text, In Str(1, txtoutput.Text, Ping )))))) check for error If InStr(1, pingresult, Reply ) = 0 Then Dim message As String

If InStr(1, pingresult, Hardware ) 0 Then message = HARDWARE FAULT Else If InStr(1, pingresult, Request ) 0 Then message = Request time out Else If InStr(1, pingresult, Destination ) 0 Then message = Destination Computer is not reachabl e Else message = pingresult End If End If End If pingresult =

ERROR with

& txtIP.Text & :

& message

pingmessage txtpinglog.Text = For i = 0 To 22 pingMessage(i) = pingMessage(i + 1) If pingMessage(i + 1) Then If txtpinglog.Text Then txtpinglog.Text = txtpinglog.Text & vbCrLf End If txtpinglog.Text = txtpinglog.Text & pingMess age(i + 1) End If Next pingMessage(23) = pingresult If txtpinglog.Text Then txtpinglog.Text = txtpinglog.Text & vbCrLf End If txtpinglog.Text = txtpinglog.Text & pingresult For i = 0 To 31 pbrtime(i).Value = pbrtime(i + 1).Value Next pbrtime(32).Value = 0

loging If chklog.Value = 1 Then If errorflag = False Then errorflag = True Open c:\pinglog.txt For Append As #2 Print #2, Now Print #2, pingresult Print #2, String(91, * ) Close #2 End If End If lcount = 0 mindelay = 0 maxdelay = 0 avgdelay = 0 totaldelay = 0

lblmin = mindelay lblmax = maxdelay lblavg = avgdelay Else lcount = lcount + 1 Ptime = CInt(Mid(txtoutput.Text, InStr(1, txtoutput.Text, tim e ) + 5, InStr(1, txtoutput.Text, ms ) InStr(1, txtoutput.Text, time ) 5)) pbyte = CInt(Mid(txtoutput.Text, InStr(1, txtoutput.Text, byt es= ) + 6, InStr(1, txtoutput.Text, time ) InStr(1, txtoutput.Text, bytes= ) 6)) pttl = CInt(Mid(pingresult, InStr(1, pingresult, TTL= ) + 4, Le n(pingresult) InStr(1, pingresult, TTL= ) 5)) tmin = CInt(Mid(txtoutput.Text, InStr(1, mum = ) + 10, InStr(InStr(1, txtoutput.Text, Minimum = ), 1, txtoutput.Text, Minimum = ) 10)) tmax = CInt(Mid(txtoutput.Text, InStr(1, mum = ) + 10, InStr(InStr(1, txtoutput.Text, Maximum = ), 1, txtoutput.Text, Maximum = ) 10)) tavg = CInt(Mid(txtoutput.Text, InStr(1, age = ) + 10, InStr(InStr(1, txtoutput.Text, Average = ), , txtoutput.Text, Average = ) 10))

txtoutput.Text, txtoutput.Text,

Mini ms, )

InStr(

txtoutput.Text, txtoutput.Text,

Maxi ms, )

InStr(

txtoutput.Text, txtoutput.Text,

Aver ms )

InStr(1

If mindelay = 0 Then mindelay = tmin If tmin < mindelay Then mindelay = tmin End If If tmax > maxdelay Then maxdelay = tmax End If totaldelay = totaldelay + tavg avgdelay = CInt(totaldelay / lcount) lblmin = mindelay lblmax = maxdelay lblavg = avgdelay If avgdelay > 0 Then For Each ctrl In frmmain If TypeOf ctrl Is ProgressBar Then ctrl.Max = avgdelay * 10 End If Next End If

ime & ms TTL=

1)

pingresult = Reply from & txtIP.Text & : bytes= & pbyte & & pttl txtpinglog.Text = For i = 0 To 22 pingMessage(i) = pingMessage(i + 1) If pingMessage(i + 1) Then If txtpinglog.Text Then txtpinglog.Text = txtpinglog.Text & vbCrLf End If txtpinglog.Text = txtpinglog.Text & pingMessage(i +

time= & Pt

End If Next pingMessage(23) = pingresult If txtpinglog.Text Then txtpinglog.Text = txtpinglog.Text & vbCrLf End If txtpinglog.Text = txtpinglog.Text & pingresult

loging If chklog.Value = 1 Then If errorflag = True Then errorflag = False Open c:\pinglog.txt For Append As #2 Print #2, Now Print #2, Reconnected with & txtIP.Te xt Print #2, String(91, * ) Close #2 End If End If On Error Resume Next Ptime = CInt(Mid(txtoutput.Text, InStr(1, txtoutput. Text, time= ) + 5, InStr(1, txtoutput.Text, ms ) InStr(1, txtoutput.Text, time= ) For i = 0 To 31 pbrtime(i).Value = pbrtime(i + 1).Value Next pbrtime(32).Value = Ptime End If Close #1 End If Else frmmain.MousePointer = 0 VarX = MsgBox( You have not entered an ip address or the number of times y ou want to ping. , vbCritical, Error has occured ) End If Wend End Sub Private Sub Command1_Click() Load frmAbout frmAbout.Show 1 End Sub Private Sub Form_Load() errorflag = False totaldelay = 0 mindelay = 0 maxdelay = 0 avgdelay = 0 lcount = 0 Open C:\log.txt For Output As #1 Close #1 End Sub

5))

Private Sub SelectText(ByRef textObj As RichTextBox) textObj.SelStart = 0 textObj.SelLength = Len(textObj) End Sub Private Sub Label6_Click() End Sub Private Sub Form_Unload(Cancel As Integer) End End Sub Private Sub Label2_Click() End Sub Private Sub Slider1_Change() Select Case Slider1.Value Case 0: txtbuffer.Text = 1000 Case 1: txtbuffer.Text = 2000 Case 2: txtbuffer.Text = 3000 Case 3: txtbuffer.Text = 4000 End Select lcount = 0 mindelay = maxdelay = avgdelay = totaldelay

0 0 0 = 0

lblmin = mindelay lblmax = maxdelay lblavg = avgdelay End Sub Private Sub Timer1_Timer() End Sub Private Sub txtIP_GotFocus() Call SelectText(txtIP) End Sub Private Sub txtOutput_GotFocus() Call SelectText(txtoutput) End Sub Private Sub txtStatus_Click() txtIP.SetFocus End Sub y, April 15, 2008 Jam Analog Buat Form dan 1 Timer

Option Explicit Dim xgen, ygen, xmin, ymin, xsec, ysec, xhor, yhor As Double Dim h, m, s As Date control the minute Function mint() If s >= 0 And s < 12 Then Call findminangle(CDbl(m)) ElseIf s >= 12 And s < 24 Then Call findminangle(CDbl(m) + ElseIf s >= 24 And s < 36 Then Call findminangle(CDbl(m) + ElseIf s >= 36 And s = 48 And s = 0 And m < 12 Then Call findminangle(CDbl(h) * 5) ElseIf m >= 12 And m < 24 Then Call findminangle(5 * (CDbl(h) + 0.2)) ElseIf m >= 24 And m < 36 Then Call findminangle(5 * (CDbl(h) + 0.4)) ElseIf m >= 36 And m < 48 Then Call findminangle(5 * (CDbl(h) + 0.6)) ElseIf m >= 48 And m = Form1.ScaleWidth / 2 And yhor >= Form1.ScaleHeight / 2 Then Line (Form1.ScaleWidth / 2, RGB(0, 0, 255) ElseIf xhor = Form1.ScaleHeight / 2 Then Form1.ScaleHeight / 2)-(xhor + 200, yhor 200 / 2 And yhor
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF