CariDotMy

 Forgot password?
 Register

ADVERTISEMENT

View: 9219|Reply: 14

Dictionary menggunakan vb. minta tolong kepada yang mahir.

[Copy link]
Post time 8-3-2012 01:00 PM | Show all posts |Read mode
masalah saya skrg ni, bila saya debug je program ni dan tekan perkataan untuk mencari maksudnya dalam bahasa inggeris, ianya akan load lama sgt. kadang2 sampai not responding. ini contoh code yang saya guna. boleh tk bg tips untuk ringkaskan lagi code ni dan mempercepatkan lagi program ni.


    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        If TextBox1.Text = "a" Then
            TextBox2.Text = "Huruf pertama dalam abjad rumi dan juga bermaksud sebuah, suatu, seorang, sebiji dll"
        ElseIf TextBox1.Text = "abaca" Then
            TextBox2.Text = "abaka, sejenis pokok"
        ElseIf TextBox1.Text = "aback" Then
            TextBox2.Text = "kebelakang"
        ElseIf TextBox1.Text = "abacus" Then
            TextBox2.Text = "detak-detak, sempoa sejenis alat penghitung"
        ElseIf TextBox1.Text = "abaft" Then
            TextBox2.Text = "pada (dekat) bunyikan kapal"

       End If
    End Sub
End Class
Reply

Use magic Report


ADVERTISEMENT


Post time 8-3-2012 10:57 PM | Show all posts
program ni bleh translate 5 perkataan jer ker?

btw utk terjemahan tu x profesional di masukkan sebagai hard code. kan lebih elok kalo dimasukkan ke dalam fail lain such as text fail ker...
Reply

Use magic Report

 Author| Post time 8-3-2012 11:49 PM | Show all posts
eh tak laa. kalau boleh nak buat kamus sebetul-betul kamusnya. hee. dari A sampai Z.

"kan lebih elok kalo dimasukkan ke dalam fail lain such as text fail ker..."
tk berapa faham la. boleh jelaskan lebih detail tak?

terima kasih kerana sudi menjawab soalan saya ini.
Reply

Use magic Report

Post time 9-3-2012 12:23 AM | Show all posts
"kan lebih elok kalo dimasukkan ke dalam fail lain such as text fail ker..."
moltenx Post at 8-3-2012 23:49


what i mean is part of software design n maintenance.

dr segi design kalo nak masukkan perkataan huruf dr A smpi Z ke dalam hardcord, coding tu akan jd panjang dan next time susah nak edit takrifan perkataan dlm kamus tu.
so, bg memudahkan design, hard code just main peranan utk cari perkataan dan memaparkan perkataan sahaja. so maklumat2 semua disimpan di dalam 1 fail lain. fail lain ni kira mcm database. nak best pki databse yg canggih skit mcm sql, kureng skit amik excel or access atau paling cikai amik notepad pun blh.

err kalo x paham jgk, i cant help u la....
Reply

Use magic Report

 Author| Post time 9-3-2012 12:32 AM | Show all posts
Reply 4# otai_g


   ohh. okay. skrg da faham! sori2 blur sikit tadi. hm thanks! ianya sangat berguna. huhu. terima kasih sgt2.
Reply

Use magic Report

Post time 9-3-2012 12:37 AM | Show all posts
TT dah belajar database ke?
Dah belajar dah ke nak connect VB tu dengan database?
MySQL ke SQLite ke Access ke?

Paling cikai pun guna ajerlah TXT file, isi dictionary tu line by line, lepas tu baca file guna VB.

errrr... TT dah belajar bukak TXT file guna VB ke?
Reply

Use magic Report

Follow Us
 Author| Post time 9-3-2012 12:48 AM | Show all posts
tgh belajar kat youtube on how to connect vb with access. sql belum mahir lagi.
Reply

Use magic Report

Post time 9-3-2012 12:51 AM | Show all posts
Selamat beraccess...
Reply

Use magic Report


ADVERTISEMENT


Post time 9-3-2012 09:30 AM | Show all posts
nanti malam sy akan buatkan coding utk dictionary nih..
Reply

Use magic Report

Post time 9-3-2012 11:46 PM | Show all posts
Edited by otai_g at 17-8-2023 08:41 AM

Post Last Edit by otai_g at 17-3-2012 20:45

okies siap jgk akhirnya.

1st copy file database dulu dlm notepad dan namakan sebagai kamus.txt -> letakkan fail ni dlm partition C:\
cth fail :-


  1. abaca=abaka, sejenis pokok
  2. aback=kebelakang
  3. abacus=detak-detak, sempoa sejenis alat penghitung
  4. abaft=pada (dekat) bunyikan kapal           
Copy the Code


my vb coding. x brp kemas, maybe otai2 leh cunkan skit coding ni. p/s: coding ni ada bug.


  1. 'copyright reserved
  2. Private Sub Command1_Click()

  3. 'data initialize
  4. DBPath = "c:"
  5. strBackSlash = IIf(Right$(DBPath, 1) = "", "", "")
  6. strFileName = DBPath & strBackSlash & "kamus.txt"

  7. 'routine to calculate total lines of dictionary file
  8. Dim counter As Long, tmp As String
  9. counter = 0
  10. Open strFileName For Input As #1
  11. While Not EOF(1)
  12.       Line Input #1, tmp
  13.       counter = counter + 1
  14. Wend
  15. Close #1

  16. 'routine to store every line into array
  17. Dim strArray() As String
  18. Open strFileName For Input As #1
  19. strArray = Split(Input(LOF(1), 1), vbCrLf)
  20. Close #1

  21. 'routine to searching data
  22. For i% = 0 To counter
  23.     If Split(strArray(i%), "=")(0) = Text1.Text Then
  24.         found% = i
  25.         Text2.Text = Split(strArray(found%), "=")(1)
  26.         Exit For
  27.         
  28. '     Else
  29. '       MsgBox "Words Not Found. Try Again.", 0
  30. '      Exit For
  31.         
  32.     End If
  33. Next

  34. End Sub

  35. Private Sub exit_Click()
  36.     Unload Me
  37. End Sub

  38. Public Sub Form_Load()

  39. Text1.Text = "<words>"
  40. Text2.Text = "<translation>"

  41. End Sub
Copy the Code


cth hasil akhir, program yg dah siap :-

Reply

Use magic Report

 Author| Post time 12-3-2012 06:06 PM | Show all posts
Reply 10# otai_g


   hm. terima kasih byk2 otai_g. walaupun mcm blur sikit baca kod2 tu. tp skrg da faham =D
Reply

Use magic Report

Post time 13-3-2012 11:08 AM | Show all posts
Reply 11# moltenx

senang je algorithm program ni.

1. dia akan kira brp total line yg ada dlm kamus.txt
2. dia akan simpan setiap line dlm 1 array. thats mean kalo ada 100 line, 100 array la -> cr ni x brp baik sbb lg bnyk array lg slow performance.
3. dia akan search perkataan yg kita nak cr dlm array tu n display maknanya. makna setiap perkataan adalah selepas simbol =

actually coding ni bkn 100% aku buat. ada certain2 part rembat dr internet jah. n then sbg programmer kita x perlu la tau for every single line, kalo tau apa function tu buat pun da cukup sbb dlm certain2 situation kena pki jgk outsourcing like api, database engine n so on..
Reply

Use magic Report

Post time 1-4-2012 10:39 PM | Show all posts
Reply

Use magic Report

Post time 1-4-2012 11:59 PM | Show all posts
tak bagus ke guna collection?
abundek Post at 1/4/2012 10:39 PM



memanglah bagus Collection tu (malah lagi efisyen daripada Array) tapi otai_g bagi contoh yang basic, tak payah nak bergantung kepada mana-mana external library, kurang sikit dependency hell tu.....
Reply

Use magic Report

Post time 2-10-2013 08:37 AM | Show all posts
haaa....mcm nie la baru bagus....
nak tanya tapi beri satu bukti yg mana ko dh usaha... gud!!!
teruskan...


Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

 

ADVERTISEMENT



 

ADVERTISEMENT


 


ADVERTISEMENT
Follow Us

ADVERTISEMENT


Mobile|Archiver|Mobile*default|About Us|CariDotMy

27-12-2024 12:30 AM GMT+8 , Processed in 0.051837 second(s), 28 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

Quick Reply To Top Return to the list