//honeypot demagogic

 Forum DhammaCitta. Forum Diskusi Buddhis Indonesia

Author Topic: [help]Seleksi Text  (Read 3898 times)

0 Members and 1 Guest are viewing this topic.

Offline Satria

  • Sahabat Baik
  • ****
  • Posts: 673
  • Reputasi: -17
  • Semoga semua mahluk berbahagia
[help]Seleksi Text
« on: 25 November 2010, 07:15:32 AM »
Bro.. saya datang ke sini mo minta tolong..saya ada masalah dalam pemrograman. padahal saya sangat membutuhkan program ini untuk kebutuhan pribadi dan kebutuhan kerja saya sehari-hari. jadi, bro yang baik hati, mudah-mudahan mau bantu saya menyelesaikan program ini.

sebenarnya, masalah ini sudah pernah di post di forum lain. tapi lom ktemu solusinya. jadi, saya nyari-nyari forum lain, dan ketemu forum ini. barangkali di sini ada yang bisa bantu saya. terima kasih sebelumnya.

Quote from: Aristotelian;318560152
Kawan-kawan semua dan para master programmer, saya mau minta tolong. Bagaimana cara agar bisa menyeleksi semua kata yang dicari dalam textbox?

Berikut ini adalah code yang saya gunakan untuk mencari text :

Code: [Select]
Private Sub Find_Click()

Dim strSearch As String, intWhere As Integer
    Dim ctlTextToSearch As Control
    ' Get search string from user.
    With Me!URAI
        strSearch = InputBox("Masukan kata yang dicari:")
        ' Find string in text.
        intWhere = InStr(.Value, strSearch)
        If intWhere Then
            ' If found.
            .SetFocus
            .SelStart = intWhere - 1
            .SelLength = Len(strSearch)
           
        Else
            ' Notify user.
            MsgBox "Kata yang dicari tidak ditemukan"
        End If
    End With

End Sub

Dan hasilnya seperti berikut :



Spoiler: ShowHide




Saya bermaksud agar semua kata “batin” terseleksi. Tapi pada kasus diatas, yang terseleksi hanya satu.  Jadi, bagaimanakah cara agar semua kata yang dicari bisa diseleksi?


Offline Sumedho

  • Kebetulan
  • Administrator
  • KalyanaMitta
  • *****
  • Posts: 12.406
  • Reputasi: 423
  • Gender: Male
  • not self
Re: [help]Seleksi Text
« Reply #1 on: 25 November 2010, 07:49:57 AM »
kalau pake model selection gitu, apakah kita bisa select multiple part of text pada waktu yg bersamaan? Kekna tidak bisa. makanya tidak akan bisa.

Biasanya utk search result itu di highlight, bukan di select
There is no place like 127.0.0.1

Offline johan3000

  • KalyanaMitta
  • *****
  • Posts: 11.552
  • Reputasi: 219
  • Gender: Male
  • Crispy Lotus Root
Re: [help]Seleksi Text
« Reply #2 on: 25 November 2010, 09:25:55 AM »
boleh tau kalau semua kata2 dlm kalimat tsb udah diselect, kemudian mau diapakan ?

apakah bisa diubah menjadi array dgn jumlah baris kalimat tsb,
kemudian per baris huruf yg ketemu, font fore ground/back groundnya diubah ?

Nagasena : salah satu dari delapan penyebab matangnya kebijaksanaan dgn seringnya bertanya

Offline Satria

  • Sahabat Baik
  • ****
  • Posts: 673
  • Reputasi: -17
  • Semoga semua mahluk berbahagia
Re: [help]Seleksi Text
« Reply #3 on: 26 November 2010, 10:11:45 PM »
kalau pake model selection gitu, apakah kita bisa select multiple part of text pada waktu yg bersamaan? Kekna tidak bisa. makanya tidak akan bisa.

Biasanya utk search result itu di highlight, bukan di select

ada program yang gratisan yang bisa melakukan seperti itu. namanya CintaNotes. ada di majalah PCMild. tapi karena program tersbut banyak kelemahannya, maka saya ingin membuat sendiri program seperti itu.

Offline Satria

  • Sahabat Baik
  • ****
  • Posts: 673
  • Reputasi: -17
  • Semoga semua mahluk berbahagia
Re: [help]Seleksi Text
« Reply #4 on: 26 November 2010, 10:12:46 PM »
boleh tau kalau semua kata2 dlm kalimat tsb udah diselect, kemudian mau diapakan ?

apakah bisa diubah menjadi array dgn jumlah baris kalimat tsb,
kemudian per baris huruf yg ketemu, font fore ground/back groundnya diubah ?

maksudnya penyeleksian tersebut untuk memudahkan  kita melihat kata atau kalimat yang kita cari dalam sebuah notes.

Offline johan3000

  • KalyanaMitta
  • *****
  • Posts: 11.552
  • Reputasi: 219
  • Gender: Male
  • Crispy Lotus Root
Re: [help]Seleksi Text
« Reply #5 on: 26 November 2010, 11:34:24 PM »
maksudnya penyeleksian tersebut untuk memudahkan  kita melihat kata atau kalimat yang kita cari dalam sebuah notes.

kelihatannya yg dimaksud adalah
changeTextColor( cSearch, cText, cColor)

dimana cColor terdapat fore ground n back ground text gitu !

bukan text selection..
Nagasena : salah satu dari delapan penyebab matangnya kebijaksanaan dgn seringnya bertanya

Offline johan3000

  • KalyanaMitta
  • *****
  • Posts: 11.552
  • Reputasi: 219
  • Gender: Male
  • Crispy Lotus Root
change color in VBA word...
« Reply #6 on: 26 November 2010, 11:46:17 PM »
This is not from 2007, but the idea should suit. This example changes any current highlight to the new default highlight (wdBrightGreen) and any green text to red.

Sub ChangeColor
Options.DefaultHighlightColorIndex = wdBrightGreen

    Selection.Find.ClearFormatting
    Selection.Find.Highlight = True
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Highlight = True
    Selection.Find.Execute Replace:=wdReplaceAll

    Selection.Find.ClearFormatting
    Selection.Find.Font.Color = wdColorBrightGreen
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Color = wdColorRed
    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub


dari pada capek2 menggantikanwarna kata2 yg diinginkan,... VBA ini dpt melakukannya dgn mudah... letakan code tsb dlm macro nya word...
Nagasena : salah satu dari delapan penyebab matangnya kebijaksanaan dgn seringnya bertanya

Offline Satria

  • Sahabat Baik
  • ****
  • Posts: 673
  • Reputasi: -17
  • Semoga semua mahluk berbahagia
Re: [help]Seleksi Text
« Reply #7 on: 27 November 2010, 09:53:15 PM »
tapi bro... VBA word itu beda dgn VBA Acces. saya pikir, macro word gak bisa digunakan di Acces. 

Offline johan3000

  • KalyanaMitta
  • *****
  • Posts: 11.552
  • Reputasi: 219
  • Gender: Male
  • Crispy Lotus Root
Re: [help]Seleksi Text
« Reply #8 on: 27 November 2010, 11:49:07 PM »
tapi bro... VBA word itu beda dgn VBA Acces. saya pikir, macro word gak bisa digunakan di Acces. 

seluruh ms office ditulis dlm vbasic, jadi kemungkinan besar bisa aja...
Nagasena : salah satu dari delapan penyebab matangnya kebijaksanaan dgn seringnya bertanya

Offline Satria

  • Sahabat Baik
  • ****
  • Posts: 673
  • Reputasi: -17
  • Semoga semua mahluk berbahagia
Re: [help]Seleksi Text
« Reply #9 on: 29 November 2010, 07:10:36 AM »
seluruh ms office ditulis dlm vbasic, jadi kemungkinan besar bisa aja...

bro johan lom coba sendiri, ya?

menurut pengalaman saya, beberapa VBA word bisa digunakan di acces. tapi beberapa tidak bisa. dan code yang bro kasih itu, saya tidak mencobanya, karena yakin bahwa itu tidak akan digunakan dalam acces.

code ini :

Quote
Selection.Find.Replacement.Font.Color = wdColorRed

khusus untuk VBA word saja.

kalau dalam acces codenya begini :

Quote
text1.forecolor=vbred

Offline hatRed

  • KalyanaMitta
  • *****
  • Posts: 7.400
  • Reputasi: 138
  • step at the right place to be light
Re: [help]Seleksi Text
« Reply #10 on: 29 November 2010, 08:50:50 AM »
ini mau ngapain sih, gak ngerti :hammer:
i'm just a mammal with troubled soul



Offline johan3000

  • KalyanaMitta
  • *****
  • Posts: 11.552
  • Reputasi: 219
  • Gender: Male
  • Crispy Lotus Root
Re: [help]Seleksi Text
« Reply #11 on: 29 November 2010, 09:06:17 AM »
ini mau ngapain sih, gak ngerti :hammer:

bro hatRed, dia pingin highlight text

Quote
How it works

As well as the usual controls bound to fields, the continuous form shown above has:
cboField: an unbound yellow combo in the Form Header, where you select a field from a value list. (The code assumes the controls and fields have the same name.)
txtSearchText: a unbound yellow text box in the Form Header, where you enter some characters to match.
txtSearchDisplay: a gray text box in the Detail section, to display highlighted matches.
The idea is to include an HTML tag in set the ControlSource of txtSearchDisplay to highlight the search characters. Since its TextFormat property is Rich Text, Access knows what to do with the HTML tag.
For the example above where we searched the CompanyName field for the characters "AR", the ControlSource will become:
=Replace([CompanyName], "ar", "<b>ar</b>"))
In practice, Replace() cannot cope with Nulls, so we must test for Null. And for demonstration purposes, we used a red font tag instead of bold. The expression ends up as:
=IIf([CompanyName] Is Null, Null, Replace([CompanyName], "ar", "<font color=""red"">ar</font>"))
The AfterUpdate event of cboField repositions txtSearchDisplay over the top of the chosen field (by setting its Top and Left properties.) At design time, we used Bring To Front (on the Arrange tab of the Form Design Tools ribbon) so it sits in front of the other controls.

The AfterUpdate event of txtSearchText applies/removes the form's Filter, and shows/hides txtSearchDisplay with the right ControlSource.

Finally, we set the TabStop property of txtSearchDisplay to No, so it does not receive focus as the user tabs through the form. And just in case the user clicks on it, we use its Enter event to SetFocus to the text box bound to the real field. (Naturally, this suppresses the highlighting, but only on the current record.)

mungkin begitu ?
Nagasena : salah satu dari delapan penyebab matangnya kebijaksanaan dgn seringnya bertanya

Offline Satria

  • Sahabat Baik
  • ****
  • Posts: 673
  • Reputasi: -17
  • Semoga semua mahluk berbahagia
Re: [help]Seleksi Text
« Reply #12 on: 04 December 2010, 10:06:19 PM »
lom ngerti ah.. but, tanks aja dah.

itu kan codenya tidak ditulis di jendela code tapi di unbound text. jadi, saya tidak bisa menggunakan comman button nya.

apakah kode tersebut bisa ditulis diantara private sub dan end sub?

private sub Higlighteks()

???????????

end sub

Offline johan3000

  • KalyanaMitta
  • *****
  • Posts: 11.552
  • Reputasi: 219
  • Gender: Male
  • Crispy Lotus Root
highlight multiple search term
« Reply #13 on: 05 December 2010, 07:22:55 AM »
http://www.nsftools.com/misc/SearchAndHighlight.htm

Yg ini lebih hebat lagi, jadi kita bisa MENAMBAHKAN highligh term yg ingin kita search dlm text.

contoh : pertama kita pingin tau kata GULA.... tapi selanjutnya GARAM dalam text...
maka fungsi diatas dpt melakukannya....


contoh multiple search : (gula dan kemudia garam)
kalau membuat kue, bisanya diperlukan gula, dan gula aren lebih baik dari gula tebu. tapi juga jangan lupa garam. dan kita pilih aja garam dari laut karna garam ini ada sedikut bau ikan (hahhaaa) bisa juga garam tambang.. gula ?

ini menarik utk dicoba dehhh
Nagasena : salah satu dari delapan penyebab matangnya kebijaksanaan dgn seringnya bertanya

Offline Sumedho

  • Kebetulan
  • Administrator
  • KalyanaMitta
  • *****
  • Posts: 12.406
  • Reputasi: 423
  • Gender: Male
  • not self
Re: [help]Seleksi Text
« Reply #14 on: 05 December 2010, 03:40:27 PM »
itu JS bro. andai di vb support styling css
There is no place like 127.0.0.1