'

'

Private CommonDialogAPI As New clsOpenSave

'

Dim strText, RegExp, ppp

Dim scr

Dim str

Dim S

Public txt As String

'

Dim bytes() As Byte

 

'

Sub Nadrobi()

CommonDialogAPI.Filter = "All Files|*.*"

CommonDialogAPI.CancelError = True

On Error GoTo Canceled

CommonDialogAPI.ShowOpen

GoTo NotCanceled

Canceled:

On Error GoTo 0

MsgBox "You clicked 'Cancel'."

Exit Sub

NotCanceled:

''''''''''''''''''''''''''

txt = ""

Read CommonDialogAPI.FileName '

Selection.WholeStory '

Selection = txt ' 16

End Sub

 

' 16-

Public Sub Read(NameExeRead)

txt = ""

file_length = 0

FNum = 0

 

file_name = NameExeRead

file_length = FileLen(file_name)

FNum = FreeFile

ReDim bytes(1 To file_length)

 

Open file_name For Binary As #FNum

Get #FNum, 1, bytes

Close FNum

For m = 1 To file_length

MomentenByt = Hex(bytes(m))

If Len(MomentenByt) < 2 Then MomentenByt = "0" & MomentenByt

txt = txt & MomentenByt & " "

Next m

 

End Sub

 

' 16- Word

Sub Saberi()

CommonDialogAPI.Filter = "All Files|*.*"

CommonDialogAPI.CancelError = True

On Error GoTo Canceled

CommonDialogAPI.ShowSave

GoTo NotCanceled

Canceled:

On Error GoTo 0

MsgBox "You clicked 'Cancel'."

Exit Sub

NotCanceled:

'

Selection.WholeStory

S = Selection

S = Replace(S, Chr(13), "")

S = Replace(S, Chr(10), "")

S = Replace(S, Chr(9), "")

S = Replace(S, Chr(11), "") & vbCrLf

'''''''' ( )

strText = S

On Error Resume Next

Set RegExp = CreateObject("VBScript.RegExp")

With RegExp

.Global = True

.Pattern = "\s"

strText = .Replace(strText, "")

.Pattern = "(.{2})"

strText = .Replace(strText, "%$1")

End With

Set ppp = CreateObject("ADODB.Stream")

With ppp

.Type = 2

.Charset = "ISO-8859-1"

.Open

.WriteText Unescape(strText)

.SaveToFile CommonDialogAPI.FileName, 2

.Close

End With

End Sub

 

Function Unescape(S)

Dim scr As Object

Set scr = CreateObject("MSScriptControl.ScriptControl")

scr.Language = "VBScript"

scr.Reset

Unescape = scr.Eval("unescape(""" & S & """)")

End Function

 

'

'

Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long

Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOpenfilename As OPENFILENAME) As Long

'

Private Const cdlAPIcancel = 32755

Private Type OPENFILENAME

lStructSize As Long

hwndOwner As Long

hInstance As Long

lpstrFilter As String

lpstrCustomFilter As String

nMaxCustFilter As Long

nFilterIndex As Long

lpstrFile As String

nMaxFile As Long

lpstrFileTitle As String

nMaxFileTitle As Long

lpstrInitialDir As String

lpstrTitle As String

Flags As Long

nFileOffset As Integer

nFileExtension As Integer

lpstrDefExt As String

lCustData As Long

lpfnHook As Long

lpTemplateName As String

End Type

Public Enum OFN_Flags

OFN_READONLY = &H1

OFN_OVERWRITEPROMPT = &H2

OFN_HIDEREADONLY = &H4

OFN_NOCHANGEDIR = &H8

OFN_SHOWHELP = &H10

OFN_ENABLEHOOK = &H20

OFN_ENABLETEMPLATE = &H40

OFN_ENABLETEMPLATEHANDLE = &H80

OFS_MAXPATHNAME = &H80

OFN_NOVALIDATE = &H100

OFN_ALLOWMULTISELECT = &H200

OFN_EXTENSIONDIFFERENT = &H400

OFN_PATHMUSTEXIST = &H800

OFN_FILEMUSTEXIST = &H1000

OFN_CREATEPROMPT = &H2000

OFN_SHAREAWARE = &H4000

OFN_NOREADONLYRETURN = &H8000

OFN_NOTESTFILECREATE = &H10000

OFN_NONETWORKBUTTON = &H20000

OFN_NOLONGNAMES = &H40000

OFN_EXPLORER = &H80000

OFN_NODEREFERENCELINKS = &H100000

OFN_LONGNAMES = &H200000

End Enum

Private mvarCancelError As Boolean

Private mvarDefaultExt As String

Private mvarDialogTitle As String

Private mvarFileName As String

Private mvarFileTitle As String

Private mvarFilterIndex As Integer

Private mvarFilter As String

Private mvarFlags As Long

Private mvarInitDir As String

Private mvarMaxFileSize As Integer

Private mvarhWnd As Long

Private mvarFileExt As Integer

Public Property Let FileExt(ByVal vData As Integer)

mvarFileExt = vData

End Property

 

Public Property Get FileExt() As Integer

FileExt = mvarFileExt

End Property

 

Public Property Let hWnd(ByVal vData As Long)

mvarhWnd = vData

End Property

 

Public Property Get hWnd() As Long

hWnd = mvarhWnd

End Property

 

Public Sub ShowSave()

Dim ofn As OPENFILENAME

Dim retval As Long

With ofn

.Flags = Flags

.hwndOwner = hWnd

.hInstance = 0

.lCustData = 0

.lpfnHook = 0

.lpstrDefExt = DefaultExt

.lpstrFile = FileName & String$(MaxFileSize - Len(FileName) + 1, vbNullChar)

.lpstrFileTitle = FileTitle & Space$(256)

.lpstrFilter = mvarFilter

.lpstrInitialDir = InitDir

.lpstrTitle = DialogTitle

.lpTemplateName = 0

.lStructSize = Len(ofn)

.nFileExtension = 0

.nFileOffset = 0

.nFilterIndex = FilterIndex

.nMaxCustFilter = 0

.nMaxFile = MaxFileSize

.nMaxFileTitle = 260

End With

 

retval = GetSaveFileName(ofn)

 

If retval > 0 Then

With ofn

Flags = .Flags

DefaultExt = .lpstrDefExt

FileName = Trim$(.lpstrFile)

FileTitle = Trim$(.lpstrFileTitle)

FileExt = .nFileExtension

mvarFilter = Trim$(.lpstrFilter)

InitDir = Trim$(.lpstrInitialDir)

FilterIndex = Trim$(.nFilterIndex)

End With

Else

End If

End Sub

 

Public Sub ShowOpen()

Dim ofn As OPENFILENAME

Dim retval As Long

 

With ofn

.Flags = Flags

.hwndOwner = hWnd

.hInstance = 0

.lCustData = 0

.lpfnHook = 0

.lpstrDefExt = DefaultExt

.lpstrFile = FileName & String$(MaxFileSize - Len(FileName) + 1, 0)

.lpstrFileTitle = FileTitle & Space$(256)

.lpstrFilter = mvarFilter

.lpstrInitialDir = InitDir

.lpstrTitle = DialogTitle

.lpTemplateName = 0

.lStructSize = Len(ofn)

.nFileExtension = 0

.nFileOffset = 0

.nFilterIndex = FilterIndex

.nMaxCustFilter = 0

.nMaxFile = MaxFileSize

.nMaxFileTitle = 260

End With

 

retval = GetOpenFileName(ofn)

 

If retval > 0 Then

With ofn

Flags = .Flags

DefaultExt = .lpstrDefExt

FileName = Trim$(.lpstrFile)

FileTitle = Trim$(.lpstrFileTitle)

FileExt = .nFileExtension

mvarFilter = Trim$(.lpstrFilter)

InitDir = Trim$(.lpstrInitialDir)

FilterIndex = Trim$(.nFilterIndex)

End With

Else

End If

End Sub

 

Public Property Let MaxFileSize(ByVal vData As Integer)

mvarMaxFileSize = vData

End Property

 

Public Property Get MaxFileSize() As Integer

MaxFileSize = mvarMaxFileSize

End Property

 

Public Property Let InitDir(ByVal vData As String)

mvarInitDir = vData

End Property

 

Public Property Get InitDir() As String

InitDir = mvarInitDir

End Property

 

Public Property Let Flags(ByVal vData As OFN_Flags)

mvarFlags = vData

End Property

 

Public Property Get Flags() As OFN_Flags

Flags = mvarFlags

End Property

 

Public Property Let Filter(ByVal vData As String)

 

Dim pipepos As String

 

Do While InStr(vData, "|") > 0

pipepos = InStr(vData, "|")

 

If pipepos > 0 Then

vData = Left$(vData, pipepos - 1) & vbNullChar & Right$(vData, Len(vData) - pipepos)

End If

 

Loop

 

If Right$(vData, 2) <> vbNullChar & vbNullChar Then vData = vData & vbNullChar

If Right$(vData, 2) <> vbNullChar & vbNullChar Then vData = vData & vbNullChar

 

mvarFilter = vData

End Property

 

Public Property Get Filter() As String

Dim nullpos As String

Dim tempfilter As String

 

tempfilter = mvarFilter

 

Do While InStr(tempfilter, vbNullChar) > 0

nullpos = InStr(tempfilter, vbNullChar)

 

If nullpos > 0 Then

tempfilter = Left$(tempfilter, nullpos - 1) & vbNullChar & Right$(tempfilter, Len(tempfilter) - nullpos)

End If

 

Loop

 

If Right$(tempfilter, 1) = "|" Then tempfilter = Left$(tempfilter, Len(tempfilter) - 1)

If Right$(tempfilter, 1) = "|" Then tempfilter = Left$(tempfilter, Len(tempfilter) - 1)

 

Filter = tempfilter

End Property

 

Public Property Let FilterIndex(ByVal vData As Integer)

mvarFilterIndex = vData

End Property

 

Public Property Get FilterIndex() As Integer

FilterIndex = mvarFilterIndex

End Property

 

Public Property Let FileTitle(ByVal vData As String)

mvarFileTitle = vData

End Property

 

Public Property Get FileTitle() As String

FileTitle = mvarFileTitle

End Property

 

Public Property Let FileName(ByVal vData As String)

mvarFileName = vData

End Property

 

Public Property Get FileName() As String

FileName = mvarFileName

End Property

 

Public Property Let DialogTitle(ByVal vData As String)

mvarDialogTitle = vData

End Property

 

Public Property Get DialogTitle() As String

DialogTitle = mvarDialogTitle

End Property

 

Public Property Let DefaultExt(ByVal vData As String)

mvarDefaultExt = vData

End Property

 

Public Property Get DefaultExt() As String

DefaultExt = mvarDefaultExt

End Property

 

Public Property Let CancelError(ByVal vData As Boolean)

mvarCancelError = vData

End Property

 

Public Property Get CancelError() As Boolean

CancelError = mvarCancelError

End Property

 

Private Sub Class_Initialize()

CancelError = False

DefaultExt = ""

DialogTitle = ""

FileName = ""

FileTitle = ""

Filter = "All Files (*.*)|*.*"

FilterIndex = 1

Flags = 0

InitDir = "C:\"

MaxFileSize = 260

hWnd = 0

End Sub