home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / English-Fr2056893292007.psc / Form1.frm < prev    next >
Text File  |  2007-03-29  |  13KB  |  474 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  3. Begin VB.Form Form1 
  4.    ClientHeight    =   5190
  5.    ClientLeft      =   165
  6.    ClientTop       =   450
  7.    ClientWidth     =   5880
  8.    Icon            =   "Form1.frx":0000
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   5190
  11.    ScaleWidth      =   5880
  12.    StartUpPosition =   2  'CenterScreen
  13.    Begin VB.CommandButton cmdTranslate2 
  14.       Caption         =   "interprΘter Franτais en Anglaise"
  15.       BeginProperty Font 
  16.          Name            =   "Paramount"
  17.          Size            =   12
  18.          Charset         =   0
  19.          Weight          =   400
  20.          Underline       =   0   'False
  21.          Italic          =   0   'False
  22.          Strikethrough   =   0   'False
  23.       EndProperty
  24.       Height          =   375
  25.       Left            =   960
  26.       TabIndex        =   12
  27.       Top             =   2640
  28.       Width           =   3255
  29.    End
  30.    Begin VB.TextBox Text3 
  31.       BackColor       =   &H00C0FFFF&
  32.       BeginProperty Font 
  33.          Name            =   "MS Sans Serif"
  34.          Size            =   9.75
  35.          Charset         =   178
  36.          Weight          =   400
  37.          Underline       =   0   'False
  38.          Italic          =   0   'False
  39.          Strikethrough   =   0   'False
  40.       EndProperty
  41.       Height          =   975
  42.       Left            =   120
  43.       MultiLine       =   -1  'True
  44.       TabIndex        =   10
  45.       Top             =   1080
  46.       Width           =   615
  47.    End
  48.    Begin MSComDlg.CommonDialog CommonDialog1 
  49.       Left            =   840
  50.       Top             =   3960
  51.       _ExtentX        =   847
  52.       _ExtentY        =   847
  53.       _Version        =   393216
  54.    End
  55.    Begin VB.CommandButton cmdCorrect 
  56.       Caption         =   "Correction"
  57.       Height          =   495
  58.       Left            =   4680
  59.       TabIndex        =   9
  60.       Top             =   0
  61.       Width           =   1095
  62.    End
  63.    Begin VB.CommandButton cmdClear 
  64.       Caption         =   "Clear"
  65.       Height          =   495
  66.       Left            =   4680
  67.       TabIndex        =   8
  68.       Top             =   1800
  69.       Width           =   1095
  70.    End
  71.    Begin VB.Timer Timer1 
  72.       Interval        =   300
  73.       Left            =   840
  74.       Top             =   3480
  75.    End
  76.    Begin VB.CommandButton cmdSave 
  77.       Caption         =   "Save"
  78.       Height          =   495
  79.       Left            =   4680
  80.       TabIndex        =   4
  81.       Top             =   1200
  82.       Width           =   1095
  83.    End
  84.    Begin VB.CommandButton cmdNew 
  85.       Caption         =   "New"
  86.       Height          =   495
  87.       Left            =   4680
  88.       TabIndex        =   3
  89.       Top             =   600
  90.       Width           =   1095
  91.    End
  92.    Begin VB.CommandButton cmdTranslate 
  93.       Caption         =   "interprΘter anglaise en franτais"
  94.       BeginProperty Font 
  95.          Name            =   "Paramount"
  96.          Size            =   12
  97.          Charset         =   0
  98.          Weight          =   400
  99.          Underline       =   0   'False
  100.          Italic          =   0   'False
  101.          Strikethrough   =   0   'False
  102.       EndProperty
  103.       Height          =   375
  104.       Left            =   960
  105.       Style           =   1  'Graphical
  106.       TabIndex        =   2
  107.       Top             =   2160
  108.       Width           =   3255
  109.    End
  110.    Begin VB.TextBox Text2 
  111.       BeginProperty Font 
  112.          Name            =   "MS Sans Serif"
  113.          Size            =   9.75
  114.          Charset         =   178
  115.          Weight          =   400
  116.          Underline       =   0   'False
  117.          Italic          =   0   'False
  118.          Strikethrough   =   0   'False
  119.       EndProperty
  120.       Height          =   1455
  121.       Left            =   360
  122.       MultiLine       =   -1  'True
  123.       ScrollBars      =   2  'Vertical
  124.       TabIndex        =   1
  125.       Top             =   3360
  126.       Width           =   5295
  127.    End
  128.    Begin VB.TextBox Text1 
  129.       BackColor       =   &H00C0FFFF&
  130.       BeginProperty Font 
  131.          Name            =   "Simplified Arabic"
  132.          Size            =   12
  133.          Charset         =   178
  134.          Weight          =   400
  135.          Underline       =   0   'False
  136.          Italic          =   0   'False
  137.          Strikethrough   =   0   'False
  138.       EndProperty
  139.       Height          =   945
  140.       Left            =   840
  141.       MultiLine       =   -1  'True
  142.       ScrollBars      =   2  'Vertical
  143.       TabIndex        =   0
  144.       Top             =   1080
  145.       Width           =   3495
  146.    End
  147.    Begin VB.Label Label1 
  148.       Caption         =   "Mots Franτais"
  149.       Height          =   255
  150.       Left            =   360
  151.       TabIndex        =   13
  152.       Top             =   3000
  153.       Width           =   1335
  154.    End
  155.    Begin VB.Label Label4 
  156.       Caption         =   "nombre du record"
  157.       Height          =   375
  158.       Left            =   120
  159.       TabIndex        =   11
  160.       Top             =   600
  161.       Width           =   735
  162.    End
  163.    Begin VB.Label Banner 
  164.       Height          =   255
  165.       Left            =   480
  166.       TabIndex        =   7
  167.       Top             =   4920
  168.       Width           =   4095
  169.    End
  170.    Begin VB.Label Label3 
  171.       Caption         =   "Mots Arabe"
  172.       Height          =   255
  173.       Left            =   1080
  174.       TabIndex        =   6
  175.       Top             =   720
  176.       Width           =   975
  177.    End
  178.    Begin VB.Label Label2 
  179.       Alignment       =   2  'Center
  180.       Caption         =   "English/French Translator"
  181.       BeginProperty Font 
  182.          Name            =   "Paramount"
  183.          Size            =   18
  184.          Charset         =   0
  185.          Weight          =   700
  186.          Underline       =   0   'False
  187.          Italic          =   0   'False
  188.          Strikethrough   =   0   'False
  189.       EndProperty
  190.       ForeColor       =   &H000040C0&
  191.       Height          =   495
  192.       Left            =   480
  193.       TabIndex        =   5
  194.       Top             =   120
  195.       Width           =   3975
  196.    End
  197.    Begin VB.Menu mnuFile 
  198.       Caption         =   "File"
  199.       Begin VB.Menu mnuExit 
  200.          Caption         =   "Exit"
  201.       End
  202.    End
  203.    Begin VB.Menu mnuHelp 
  204.       Caption         =   "Help"
  205.    End
  206. End
  207. Attribute VB_Name = "Form1"
  208. Attribute VB_GlobalNameSpace = False
  209. Attribute VB_Creatable = False
  210. Attribute VB_PredeclaredId = True
  211. Attribute VB_Exposed = False
  212. Dim Dictionary As Translate
  213. Dim FileNum As Integer
  214. Dim RecordLen As Long
  215. Dim CurrentRecord As Long
  216. Dim LastRecord As Long
  217. Dim X
  218. Dim RecNum As Long
  219. Dim Y As Long
  220.  
  221.  
  222. Private Sub cmdClear_Click()
  223. Text1.Text = ""
  224. Text2.Text = ""
  225. Text3.Text = ""
  226. End Sub
  227.  
  228. Private Sub cmdCorrect_Click()
  229. Dim MyNo
  230. MyNo = InputBox("Write The Record No")
  231. If MyNo <> "" Then
  232. RecNum = MyNo
  233. End If
  234. Get #FileNum, RecNum, Dictionary
  235. Text1.Text = Trim(Dictionary.Arabic)
  236. Text2.Text = Trim(Dictionary.English)
  237. Text3.Text = RecNum
  238. CurrentRecord = MyNo
  239. Form1.Caption = "Record " & Str(CurrentRecord) & " / " & Str(LastRecord)
  240. End Sub
  241.  
  242. Private Sub cmdSave_Click()
  243. 'Fill Dictionary with the currently Displayed Data
  244. Dim confirm
  245. confirm = MsgBox("Are You Sure?", vbOKCancel, "Confirm")
  246. If confirm = vbOK Then
  247. If Left(Text1.Text, 1) = "-" Then
  248. Dictionary.Arabic = Text1.Text
  249. Else
  250. Dictionary.Arabic = "- " & Text1.Text
  251. End If
  252. Dictionary.English = Text2.Text
  253.  
  254. 'Save Dictionary to the current record
  255. Put #FileNum, CurrentRecord, Dictionary
  256. 'Close #FileNum
  257. Else
  258. Exit Sub
  259. End If
  260. End Sub
  261. Public Sub SaveCurrentRecord()
  262. 'Fill Dictionary with the currently Displayed Data
  263. Dictionary.Arabic = Text1.Text
  264. Dictionary.English = Text2.Text
  265. 'Save Dictionary to the current record
  266. Put #FileNum, CurrentRecord, Dictionary
  267. End Sub
  268.  
  269. Private Sub cmdTranslate_Click()
  270. Dim NameToSearch As String
  271. Dim Found As Integer
  272.  
  273. NameToSearch = "- " & Text1.Text
  274. If NameToSearch = "" Then
  275. Text1.SetFocus
  276. Exit Sub
  277. End If
  278.  
  279. Y = 1
  280. Found = False
  281.  
  282. For RecNum = Y To LastRecord Step 1
  283. Get #FileNum, RecNum, Dictionary
  284.  
  285. 'If Trim(Dictionary.Arabic) Like ("*" & NameToSearch & "*") Then
  286. Dim a
  287. For a = 1 To Len(Dictionary.Arabic) - Len(NameToSearch) - 1
  288. If UCase(Mid(Dictionary.Arabic, a, Len(NameToSearch))) = UCase(NameToSearch) Then
  289. Found = True
  290. GoTo 10:
  291. End If
  292. Next a
  293.  
  294.  
  295. 20:
  296. Next RecNum
  297.  
  298. 10:
  299. If Found = True Then
  300.  
  301.     CurrentRecord = RecNum
  302.     Get #FileNum, CurrentRecord, Dictionary
  303.  
  304.     Text1.Text = Text1.Text & vbNewLine & CurrentRecord & "-" & Trim(Dictionary.Arabic)
  305.     Text2.Text = Text2.Text & vbNewLine & CurrentRecord & "-" & Trim(Dictionary.English)
  306.     Text3.Text = Text3.Text & vbNewLine & CStr(CurrentRecord) & "-"
  307.  
  308. End If
  309.  
  310. If RecNum < LastRecord Then
  311. Form1.Caption = "Record " & Str(CurrentRecord) & " / " & Str(LastRecord)
  312. Y = Y + 1
  313. GoTo 20
  314. Else
  315. MsgBox "Reach Last Record", vbOKOnly, "End of File"
  316. End If
  317. Text1.SetFocus
  318.  
  319.  
  320. End Sub
  321.  
  322. Private Sub cmdTranslate2_Click()
  323. Dim NameToSearch As String
  324. Dim Found As Integer
  325.  
  326.  
  327.  
  328. NameToSearch = Text2.Text
  329. If NameToSearch = "" Then
  330. Text2.SetFocus
  331. Exit Sub
  332. End If
  333. 'NameToSearch = UCase(NameToSearch)
  334.  
  335. Y = 1
  336.  
  337. Found = False
  338.  
  339. For RecNum = Y To LastRecord Step 1
  340. Get #FileNum, RecNum, Dictionary
  341. If Trim(Dictionary.English) Like ("*" & NameToSearch & "*") Then
  342. Found = True
  343. 'Exit For
  344. GoTo 10:
  345. End If
  346. 20:
  347. Next
  348. 10:
  349. If Found = True Then
  350. 'SaveCurrentRecord
  351. CurrentRecord = RecNum
  352.  
  353. 'ShowCurrentRecord
  354.  
  355. Get #FileNum, CurrentRecord, Dictionary
  356. 'Display Dictionary
  357.   
  358.     If Text2.Text <> "" Then
  359.     Text1.Text = Text1.Text & vbNewLine & Trim(Dictionary.Arabic)
  360.     Text2.Text = Text2.Text & vbNewLine & Trim(Dictionary.English)
  361.     If CurrentRecord < LastRecord Then
  362.     Text3.Text = Text3.Text & vbNewLine & CStr(CurrentRecord) & "-"
  363.     End If
  364.     Else
  365.     Text1.Text = Trim(Dictionary.Arabic)
  366.     Text2.Text = Trim(Dictionary.English)
  367.     Text3.Text = CStr(CurrentRecord) & "-"
  368.     End If
  369.     
  370. 'Display the current Record Number in the caption of the form
  371. 'Form1.Caption = "Record " & Str(CurrentRecord) & " / " & Str(LastRecord)
  372. End If
  373. If RecNum < LastRecord Then
  374. Form1.Caption = "Record " & Str(CurrentRecord) & " / " & Str(LastRecord)
  375. Y = Y + 1
  376. GoTo 20
  377. Else
  378. MsgBox "Reach Last Record", vbOKOnly, "End of File"
  379. 'MsgBox "Name " & NameToSearch & " Not Found"
  380. End If
  381. Text2.SetFocus
  382.  
  383. End Sub
  384.  
  385. Private Sub Form_Load()
  386. Form1.Icon = LoadPicture(App.Path & "\Misc43.ico")
  387. Y = 1
  388. X = 1
  389. RecordLen = Len(Dictionary)
  390. 'Get the Next Available File Number
  391. FileNum = FreeFile(1 - 10)
  392. Dim MyPath
  393. MyPath = App.Path
  394. Dim MyFile
  395. MyFile = MyPath & "\" & "Trans.txt"
  396. 'Open(or creat) a file for random access
  397. Open MyFile For Random As FileNum Len = RecordLen
  398. 'Update current record
  399. CurrentRecord = 1
  400. 'Find What is the last record number of the file
  401. LastRecord = FileLen(MyFile) / RecordLen
  402. 'If the file was just created (i.e.LastRecord=0)
  403. 'Update LastRecord to 1
  404. If LastRecord = 0 Then
  405. LastRecord = 1
  406. End If
  407. 'Display the current record
  408. 'ShowCurrentRecord       'this is a name of procedure
  409. Text1.Text = ""
  410. Text2.Text = ""
  411. Form1.Caption = "Record " & Str(CurrentRecord) & " / " & Str(LastRecord)
  412. End Sub
  413. Public Sub ShowCurrentRecord()
  414. 'Fill Dictionary with the data of the current record
  415. Get #FileNum, CurrentRecord, Dictionary
  416. 'Display Dictionary
  417. Text1.Text = Trim(Dictionary.Arabic)
  418. Text2.Text = Trim(Dictionary.English)
  419.  
  420. 'Display the current Record Number in the caption of the form
  421. Form1.Caption = "Record " & Str(CurrentRecord) & " / " & Str(LastRecord)
  422.  
  423. End Sub
  424.  
  425.  
  426. Private Sub cmdNew_Click()
  427. 'SaveCurrentRecord    'Procedure name
  428. ''add a new blank record
  429. LastRecord = LastRecord + 1
  430. Dictionary.Arabic = ""
  431. Dictionary.English = ""
  432.  
  433. Put #FileNum, LastRecord, Dictionary
  434. 'Update CurrentRecord
  435. CurrentRecord = LastRecord
  436. 'Display the record just created
  437. ShowCurrentRecord
  438. Form1.Caption = "Record " & Str(CurrentRecord) & " / " & Str(LastRecord)
  439. Text3.Text = LastRecord
  440. Text1.SetFocus
  441.  
  442. End Sub
  443.  
  444. Private Sub Form_Unload(Cancel As Integer)
  445. Close #FileNum
  446. End Sub
  447.  
  448. Private Sub mnuExit_Click()
  449. End
  450. End Sub
  451.  
  452.  
  453.  
  454. Private Sub mnuHelp_Click()
  455. Dim MyFile2, MyPath
  456. MyPath = App.Path
  457. MyFile2 = MyPath & "\Trans.hlp"
  458. Const HelpFinder = &HB&
  459. CommonDialog1.Action = 6 '6 means run winhlp32.exe
  460. CommonDialog1.HelpFile = MyFile2
  461.  
  462. CommonDialog1.HelpCommand = HelpFinder
  463. CommonDialog1.ShowHelp
  464.  
  465. End Sub
  466.  
  467. Private Sub Timer1_Timer()
  468. Banner.Caption = Mid("The Dictinary that you can add words to it", 1, X)
  469. X = X + 1
  470. If X > Len("The Dictinary that you can add words to it") Then
  471. X = 1
  472. End If
  473. End Sub
  474.