Avko |
19.10.2015 14:20 |
Predmet:usporedi dva fajla
Ova funkcija će usporediti jednu datoteke sa drugom. Moze usporediti samo duzinu datoteka ili razliku datoteka byte po byte.
Pozivate je:
usporediDatoteke(File1,File2) - samo za usporediti duzinu datoteka
usporediDatoteku(File1,File2,True) - usporeduje byte po byte datoteka
gdje su File1=App.Path & "/ime1.ext" i File2=App.Path & "/ime2.ext"
PreuzmiIzvorni kôd (Visual Basic):Function usporediDatoteke(ByVal File1 As String, _
ByVal File2 As String, Optional StringentCheck As _
Boolean = False) As Boolean
'*******************************************************************************************
'Ime: usporediDatoteke
'Namjena: Provjeri dali su dvije datoteke identicne
'Autor: Ervin Kosch
'Ulazni parametri:
' -File1 i File2 = putanje sa imenom datoteke
' -StringentCheck = if false (default), usporeduje samo duzinu
' -StringentCheck = if true , usporeduje byte po byte datoteke
'Izlazni parametri: Boolean
'********************************************************************************************
On Error GoTo ErrorHandler
If Dir(File1) = "" Then Exit Function
If Dir(File2) = "" Then Exit Function
Dim lLen1 As Long, lLen2 As Long
Dim iFileNum1 As Integer
Dim iFileNum2 As Integer
Dim bytArr1() As Byte, bytArr2() As Byte
Dim lCtr As Long, lStart As Long
Dim bAns As Boolean
lLen1 = FileLen(File1)
lLen2 = FileLen(File2)
If lLen1 <> lLen2 Then
Exit Function
ElseIf StringentCheck = False Then
usporediDatoteke = True
Exit Function
Else
iFileNum1 = FreeFile
Open File1 For Binary Access Read As #iFileNum1
iFileNum2 = FreeFile
Open File2 For Binary Access Read As #iFileNum2
'put contents of both into byte Array
bytArr1() = InputB(LOF(iFileNum1), #iFileNum1)
bytArr2() = InputB(LOF(iFileNum2), #iFileNum2)
lLen1 = UBound(bytArr1)
lStart = LBound(bytArr1)
bAns = True
For lCtr = lStart To lLen1
If bytArr1(lCtr) <> bytArr2(lCtr) Then
bAns = False
Exit For
End If
Next
usporediDatoteke = bAns
End If
ErrorHandler:
If iFileNum1 > 0 Then Close #iFileNum1
If iFileNum2 > 0 Then Close #iFileNum2
End Function
|
Gjoreski |
29.05.2018 01:07 |
Predmet:Dinamicko kreirajne Comman Button
Tri varijante kako napraviti dinamicki kontroli ( Command Button ) na forme
Verzija 1
Kreirajte nova Forma Form1 i na njoj stavite jedan command button Commatd1 i jos stavite i
Command1.index=0
Zatim iskopirajte sledeci kod na forme
PreuzmiIzvorni kôd (Visual Basic):Private Sub Form_Load()
Dim lngIndex As Long
For lngIndex = 1 To 100
Load Command1(lngIndex)
Next lngIndex
For lngIndex = 0 To Command1.UBound
With Command1(lngIndex)
.Caption = CStr(lngIndex)
.Visible = True
End With
Next lngIndex
End Sub
Private Sub Form_Resize()
Dim lngIndex As Long
Dim sngWidth As Single, sngHeight As Single
Dim lngRow As Long, lngCol As Long
sngWidth = ScaleWidth / 10
sngHeight = ScaleHeight / 10
For lngIndex = 0 To Command1.UBound
lngRow = lngIndex \ 10
lngCol = lngIndex Mod 10
Command1(lngIndex).Move lngCol * sngWidth, lngRow * sngHeight, sngWidth, sngHeight
Next lngIndex
End Sub
Verzija 2
Samo kreirajte nova forma i upisite ovaj cod:
PreuzmiIzvorni kôd (Visual Basic):Dim WithEvents Cmd1 As CommandButton
'
Private Sub Form_Load()
Set Cmd1 = Controls.Add("vb.commandbutton", "Cmd1")
Cmd1.Width = 2000
Cmd1.Top = Me.Height / 2 - Cmd1.Height / 2 - 100
Cmd1.Left = Me.Width / 2 - Cmd1.Width / 2 - 100
Cmd1.Caption = "Dynamic Button"
Cmd1.Visible = True
Set Cmd2 = Controls.Add("vb.commandbutton", "Cmd2")
Cmd2.Width = 2000
Cmd2.Top = 10
Cmd2.Left = 10
Cmd2.Caption = "Dynamic Button 2"
Cmd2.Visible = True
End Sub
'
Private Sub Cmd1_click()
MsgBox "I have been Created Dynamically at Run-time", _
, "Dynamic Controls"
End Sub
Verzija 3
Kreirajte nova forma i upisite ovaj cod :
PreuzmiIzvorni kôd (Visual Basic):Dim cmdButton(4) As CommandButton
Private Sub Form_Load()
Dim i As Integer
For i = 0 To 4
Set cmdButton(i) = Me.Controls.Add("VB.CommandButton", "cmdButton" & Me.Controls.Count)
With cmdButton(i)
.Left = 750 * i
.Top = 1000
.Width = 700
.Height = 500
.Caption = "Hello"
.Visible = True
End With
Next i
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim i As Integer
For i = 0 To 4
Set cmdButton(i) = Nothing
Next i
End Sub
|
Gjoreski |
11.06.2018 22:50 |
Predmet:Izvlacejne Broj od stinga sa decimalom
Ako nekome zatreba :
PreuzmiIzvorni kôd (Visual Basic):Public Function Extract_Number_With_Decimal(Phrase As String) As Double
Dim Length_of_String As Integer
Dim Current_Pos As Integer
Dim Temp As String
Length_of_String = Len(Phrase)
Temp = ""
For Current_Pos = 1 To Length_of_String
If (Mid(Phrase, Current_Pos, 1) = "-") Then
Temp = Temp & Mid(Phrase, Current_Pos, 1)
End If
If (Mid(Phrase, Current_Pos, 1) = ".") Then
Temp = Temp & Mid(Phrase, Current_Pos, 1)
End If
If (IsNumeric(Mid(Phrase, Current_Pos, 1))) = True Then
Temp = Temp & Mid(Phrase, Current_Pos, 1)
End If
Next Current_Pos
If Len(Temp) = 0 Then
Extract_Number_With_Decimal = 0
Else
Extract_Number_With_Decimal = CDbl(Temp)
End If
End Function
|