home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / code1a / form1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-10-14  |  10.1 KB  |  308 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  3. Begin VB.Form Form1 
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "Code"
  6.    ClientHeight    =   4965
  7.    ClientLeft      =   45
  8.    ClientTop       =   330
  9.    ClientWidth     =   6660
  10.    Icon            =   "Form1.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   4965
  15.    ScaleWidth      =   6660
  16.    ShowInTaskbar   =   0   'False
  17.    StartUpPosition =   2  'CenterScreen
  18.    Begin VB.CommandButton Command4 
  19.       Caption         =   "Open"
  20.       Height          =   375
  21.       Left            =   120
  22.       TabIndex        =   8
  23.       Top             =   4440
  24.       Width           =   1455
  25.    End
  26.    Begin MSComctlLib.ImageList ImageList1 
  27.       Left            =   4080
  28.       Top             =   1080
  29.       _ExtentX        =   1005
  30.       _ExtentY        =   1005
  31.       BackColor       =   -2147483643
  32.       ImageWidth      =   32
  33.       ImageHeight     =   32
  34.       MaskColor       =   12632256
  35.       _Version        =   393216
  36.       BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  37.          NumListImages   =   3
  38.          BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  39.             Picture         =   "Form1.frx":0FC2
  40.             Key             =   "direktorijum"
  41.          EndProperty
  42.          BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  43.             Picture         =   "Form1.frx":2786
  44.             Key             =   "kljuc"
  45.          EndProperty
  46.          BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  47.             Picture         =   "Form1.frx":375A
  48.             Key             =   "tekst"
  49.          EndProperty
  50.       EndProperty
  51.    End
  52.    Begin VB.DirListBox Dir1 
  53.       Height          =   3690
  54.       Left            =   120
  55.       TabIndex        =   6
  56.       Top             =   600
  57.       Width           =   2295
  58.    End
  59.    Begin VB.FileListBox File1 
  60.       Height          =   675
  61.       Left            =   5400
  62.       Pattern         =   "*.cod;*.txt"
  63.       TabIndex        =   5
  64.       Top             =   0
  65.       Visible         =   0   'False
  66.       Width           =   975
  67.    End
  68.    Begin VB.CommandButton Command3 
  69.       Caption         =   "Code"
  70.       Height          =   375
  71.       Left            =   1680
  72.       TabIndex        =   4
  73.       Top             =   4440
  74.       Width           =   1455
  75.    End
  76.    Begin VB.CommandButton Command2 
  77.       Caption         =   "Decode"
  78.       Height          =   375
  79.       Left            =   3240
  80.       TabIndex        =   3
  81.       Top             =   4440
  82.       Width           =   1455
  83.    End
  84.    Begin VB.CommandButton Command1 
  85.       Caption         =   "Exit"
  86.       Height          =   375
  87.       Left            =   4800
  88.       TabIndex        =   2
  89.       Top             =   4440
  90.       Width           =   1695
  91.    End
  92.    Begin MSComctlLib.ListView ListView1 
  93.       Height          =   3615
  94.       Left            =   2520
  95.       TabIndex        =   1
  96.       Top             =   720
  97.       Width           =   4095
  98.       _ExtentX        =   7223
  99.       _ExtentY        =   6376
  100.       Arrange         =   1
  101.       LabelEdit       =   1
  102.       SortOrder       =   -1  'True
  103.       Sorted          =   -1  'True
  104.       LabelWrap       =   -1  'True
  105.       HideSelection   =   0   'False
  106.       HotTracking     =   -1  'True
  107.       HoverSelection  =   -1  'True
  108.       PictureAlignment=   5
  109.       _Version        =   393217
  110.       Icons           =   "ImageList1"
  111.       SmallIcons      =   "ImageList1"
  112.       ColHdrIcons     =   "ImageList1"
  113.       ForeColor       =   -2147483640
  114.       BackColor       =   -2147483643
  115.       BorderStyle     =   1
  116.       Appearance      =   1
  117.       NumItems        =   0
  118.    End
  119.    Begin VB.DriveListBox Drive1 
  120.       Height          =   315
  121.       Left            =   120
  122.       TabIndex        =   0
  123.       Top             =   120
  124.       Width           =   2895
  125.    End
  126.    Begin VB.Label Label2 
  127.       AutoSize        =   -1  'True
  128.       Caption         =   "Selected:"
  129.       Height          =   195
  130.       Left            =   3120
  131.       TabIndex        =   9
  132.       Top             =   240
  133.       Width           =   675
  134.    End
  135.    Begin VB.Label Label1 
  136.       AutoSize        =   -1  'True
  137.       BackStyle       =   0  'Transparent
  138.       Caption         =   "Label1"
  139.       BeginProperty Font 
  140.          Name            =   "MS Sans Serif"
  141.          Size            =   8.25
  142.          Charset         =   0
  143.          Weight          =   700
  144.          Underline       =   0   'False
  145.          Italic          =   0   'False
  146.          Strikethrough   =   0   'False
  147.       EndProperty
  148.       ForeColor       =   &H00FFFF00&
  149.       Height          =   195
  150.       Left            =   3960
  151.       TabIndex        =   7
  152.       Top             =   240
  153.       Width           =   585
  154.    End
  155. Attribute VB_Name = "Form1"
  156. Attribute VB_GlobalNameSpace = False
  157. Attribute VB_Creatable = False
  158. Attribute VB_PredeclaredId = True
  159. Attribute VB_Exposed = False
  160. '                    Code and decode TextFiles
  161. '     Pretty good way to code text file;
  162. '     Code and Decode using password
  163. '     How to use some common controlls (FileListBox,
  164. '     Image list, ListView, DirLisBox, FileListBox...
  165. '     Very clean encrypting (no trash left)
  166. '                 sslavko@yubc.net
  167. '     _______________________________________________
  168. Public Sub osvezi() 'Refresh
  169. ListView1.ListItems.Clear
  170. 'For i = 0 To Dir1.ListCount - 1
  171. 'ListView1.ListItems.Add , "dir" + Right$(Str$(i), Len(Str$(i))), Right$(Dir1.List(i), Len(Dir1.List(i)) - Len(Dir1.Path)), ImageList1.ListImages.Item(1).Key, ImageList1.ListImages.Item(1).Key
  172. 'Next i
  173. Label1.Caption = Dir1.Path
  174. File1.Path = Dir1.Path
  175. For i = 0 To File1.ListCount - 1
  176. If Right$(File1.List(i), 3) = "cod" Then
  177. ListView1.ListItems.Add , "file" + Right$(Str$(i), Len(Str$(i))), File1.List(i), ImageList1.ListImages.Item(2).Key, ImageList1.ListImages.Item(2).Key
  178. ListView1.ListItems.Add , "file" + Right$(Str$(i), Len(Str$(i))), File1.List(i), ImageList1.ListImages.Item(3).Key, ImageList1.ListImages.Item(3).Key
  179. End If
  180. Next i
  181. ListView1.Refresh
  182. End Sub
  183. Private Sub Command1_Click()
  184. End Sub
  185. Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  186. Command1.SetFocus
  187. End Sub
  188. Private Sub Command2_Click()
  189. Dim slovo(1 To 80) As String
  190. 'Set password
  191. s$ = InputBox$("Password:", "Enter Password")
  192. If s$ = "" Then
  193. MsgBox "Password required!", , "Error"
  194. Exit Sub
  195. End If
  196. 'processing password
  197. For i = 1 To Len(s$)
  198.  slovo(i) = Mid$(s$, i, 1)
  199. Next i
  200. k = 1
  201. Max = i
  202. 'Read, encrypt, write
  203. If Label1.Caption = "" Then
  204. MsgBox$ "Select File.", , "Error"
  205. Exit Sub
  206. End If
  207. If Right$(Dir1.Path, 1) = "\" Then otvori$ = Dir1.Path Else otvori$ = Dir1.Path + "\"
  208. Open otvori$ + Label1.Caption For Input As 1
  209. Open otvori$ + "dekode.txt" For Output As 2
  210. Do Until EOF(1)
  211. Line Input #1, a$
  212. 'ENGINE
  213. b$ = ""
  214. posl = 1
  215. For i = 1 To Len(a$) Step 4
  216. d% = Val(Mid$(a$, i, 4)) - Asc(slovo(k))
  217. If d% = 0 Or d% > 255 Then Exit For
  218. b$ = b$ + Chr$(d%)
  219. k = k + 1
  220. If k > (Max - 1) Then k = 1
  221. Next i
  222. Print #2, b$
  223. Close #1
  224. Close #2
  225. ListView1.ListItems.Add , "file" + Label1.Caption, "dekode.txt", ImageList1.ListImages.Item(3).Key, ImageList1.ListImages.Item(3).Key
  226. End Sub
  227. Private Sub Command2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  228. Command2.SetFocus
  229. End Sub
  230. Private Sub Command3_Click()
  231. Dim slovo(1 To 80) As String
  232. Dim a As String * 80
  233. s$ = InputBox$("Password:", "Enter")
  234. If s$ = "" Then
  235. MsgBox "Enter password", , "Error"
  236. Exit Sub
  237. End If
  238. For i = 1 To Len(s$)
  239.  slovo(i) = Mid$(s$, i, 1)
  240. Next i
  241. k = 1
  242. Max = i
  243. If Label1.Caption = "" Then
  244. MsgBox "Select File.", vbOKOnly, "Error"
  245. Exit Sub
  246. End If
  247. If Right$(Dir1.Path, 1) = "\" Then otvori$ = Dir1.Path + Label1.Caption Else otvori$ = Dir1.Path + "\" + Label1.Caption
  248. fajl$ = Left$(otvori$, Len(otvori$) - 4) + ".cod"
  249. Open otvori$ For Input As 1
  250. Open fajl$ For Output As 2
  251. Do Until EOF(1)
  252. Line Input #1, a
  253. 'ENGINE
  254. b$ = ""
  255. For i = 1 To 80
  256. d% = Asc(Mid$(a, i, 1)) + Asc(slovo(k))
  257. b$ = b$ + Str$(d%)
  258. k = k + 1
  259. If k > (Max - 1) Then k = 1
  260. Next i
  261. Print #2, b$
  262. Close #1
  263. Close #2
  264. ListView1.ListItems.Add , "file" + Label1.Caption, Left$(Label1.Caption, Len(Label1.Caption) - 4) + ".cod", ImageList1.ListImages.Item(2).Key, ImageList1.ListImages.Item(2).Key
  265. End Sub
  266. Private Sub Command3_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  267. Command3.SetFocus
  268. End Sub
  269. Private Sub Command4_Click()
  270. If LCase$(Right$(Label1.Caption, 3)) = "txt" Then
  271. Form2.Show
  272. MsgBox "TextFiles only!", vbOKOnly, "Error"
  273. End If
  274. End Sub
  275. Private Sub Command4_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  276. Command4.SetFocus
  277. End Sub
  278. Private Sub Dir1_Change()
  279. ListView1.ListItems.Clear
  280. 'For i = 0 To Dir1.ListCount - 1
  281. 'ListView1.ListItems.Add , "dir" + Right$(Str$(i), Len(Str$(i))), Right$(Dir1.List(i), Len(Dir1.List(i)) - Len(Dir1.Path)), ImageList1.ListImages.Item(1).Key, ImageList1.ListImages.Item(1).Key
  282. 'Next i
  283. Label1.Caption = ""
  284. File1.Path = Dir1.Path
  285. For i = 0 To File1.ListCount - 1
  286. If Right$(File1.List(i), 3) = "cod" Then
  287. ListView1.ListItems.Add , "file" + Right$(Str$(i), Len(Str$(i))), File1.List(i), ImageList1.ListImages.Item(2).Key, ImageList1.ListImages.Item(2).Key
  288. ListView1.ListItems.Add , "file" + Right$(Str$(i), Len(Str$(i))), File1.List(i), ImageList1.ListImages.Item(3).Key, ImageList1.ListImages.Item(3).Key
  289. End If
  290. Next i
  291. End Sub
  292. Private Sub Dir1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  293. Dir1.SetFocus
  294. End Sub
  295. Private Sub Drive1_Change()
  296. Dir1.Path = Drive1.Drive
  297. File1.Path = Dir1.Path
  298. End Sub
  299. Private Sub Form_Load()
  300. Dir1.Path = "c:\My Documents"
  301. osvezi
  302. Label1.Caption = ""
  303. End Sub
  304. Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
  305. Label1.Caption = Item.Text
  306. Command3.Enabled = True
  307. End Sub
  308.