bagi aku juga ya.. heheheh --- Bace - Bace <[EMAIL PROTECTED]> wrote:
> ntar bagi2 ya program sms centernya.... > > Semoga membantu: =(oVo)= > ==================== > BaceInside Publisher > Copyright @2007 > Not for reproduced, republished. > Thank You > ==================== > > > > ----- Original Message ---- > From: bambang supriadi <[EMAIL PROTECTED]> > To: [email protected] > Sent: Thursday, May 10, 2007 2:18:13 PM > Subject: Re: [indoprog-vb] Re: Gimana ngambil string > per karakter > > Makasih modulnya. Aplikasinya buat sms server. Kalo > ngambil data dari inbox HP kan semua kalimatnya > diambil sementara aku pengen misahin perkata, > kata-kata itu merupakan kata kunci yang bakalan > disimpen ke database sesuai dengan tabelnya masing > masing jadi satu kata punya satu database yang > berbeda dengan kata lain kan. Nah pemisah masing2 > kata kunci itu spasi, kadang-kadang kan ada ya orang > ngetik buru2 jadi spasinya kelebihan aku pengennya > kode program aku nanti bisa mengabaikan pengetikan > spasi yang berlebih jadi tetep bisa ngambil kata > kunci berikutnya. > > Maap merepotkan!! ! Matur nuwun nanti saya coba klu > ada kesulitan saya nanya lagi dan bakalan ngerepotin > lagi. > > Bace - Bace <[EMAIL PROTECTED] com> wrote: banyak cara > untuk mencari karakter tertentu didalam kalimat/kata > didalam visual basic. Permasalahnya adalah bagaimana > menentukan cara tersebut cocok sesuai dengan > keingginan mu. Tujuan pencarian kata tersebut untuk > apa? > - Untuk menampilkan satu kalimat yang memiliki kata > tertent > - Untuk mengambil kata tertentu didalam kalimat yang > ada > - Untuk mencari kata tertentu, dan kemudian membuat > nya menjadi kalimat baru(memisahkan mereka) > - Untuk mencari dan mengganti kata tertentu dgn kata > lain (find and replase) > - dll > > untuk semua tujuan diatas, kode yang dipakai > harusnya kode yang efisein, sesuai dengan tujuannya. > == > > untuk bahan mu lebih lanjut pelajari modul dibawa > ya.., semua kodenya ada dibawah sana: > Working with Strings > Visual Basic for Applications includes many powerful > string functions, and it's sometimes difficult at > first glance to determine which one meets your > requirements. In this section, I briefly describe > all the string functions at your disposal, offer > some tips for selecting the most suitable one in > some typical situations, and also provide some > useful string functions that you can reuse in your > applications. > Basic String Operators and Functions > The basic string operator & performs a string > concatenation. The result is a string consisting of > all the characters of the first string followed by > all the characters of the second string: > Print "ABCDE" & "1234" ' Displays "ABCDE1234" > > Many programmers with roots in QuickBasic still use > the + operator for performing string concatenation. > This is a dangerous practice that impacts code > readability and might introduce unexpected behaviors > when either operand isn't a string. > The next bunch of popular string functions, shown > below, includes Left$, Right$, and Mid$, which > extract a substring from the beginning, the end, or > the middle of the source string. > Text = "123456789" > Print Left$(text, 3) ' Displays "123" > Print Right$(text, 2) ' Displays "89" > Print Mid$(text, 3, 4) ' Displays "3456" > > TIP > > The VBA documentation consistently omits the > trailing $ character in all string functions and > invites you to use the new $-less functions. Don't > do it! A $-less function returns a Variant that > contains the string result, which means in most > cases the Variant must be reconverted to a string > before it can be reused in expressions or assigned > to a String variable. This is a time-consuming > process that gives you nothing in return. Informal > benchmarks show that, for example, the Left$ > function is up to twice as fast as its $-less > counterpart. A similar reasoning applies to other > functions that exist in both forms, including LCase, > UCase, LTrim, RTrim, Trim, Chr, Format, Space, and > String. > Mid$ can also work as a command in that it lets you > modify one or more characters inside a string: > Text = "123456789" > Mid$(Text, 3, 4) = "abcd" ' Now Text = "12abcd789" > > The Len function returns the current length of a > string. It's often used to test whether a string > contains any characters: > Print Len("12345") ' Displays "5" > If Len(Text) = 0 Then ... ' Faster than comparison > with an empty string. > > To discard unwanted trailing or leading blanks, you > can use the LTrim$, RTrim$, and Trim$ functions: > Text = " abcde " > Print LTrim$(Text) ' Displays "abcde " > Print RTrim$(Text) ' Displays " abcde" > Print Trim$(Text) ' Displays "abcde" > > These functions are especially useful with > fixed-length strings that are filled with extra > spaces to account for their expected length. You can > trim those extra spaces using the RTrim$ function: > Dim Text As String * 10 > Text = "abcde" ' Text now contains "abcde ". > Print Trim$(Text) ' Displays "abcde" > > CAUTION > > When a fixed-length string is declared but hasn't > been used yet, it contains Null characters, not > spaces. This means that the RTrim$ function can't > trim such a string: > Dim Text As String * 10 > Print Len(Trim$(Text) ) ' Displays "10", no trimming > has occurred. > > You can avoid this problem by simply assigning an > empty string to all the fixed-length strings in your > application soon after their declaration and before > using them. > The Asc function returns the character code of the > first letter in a string. Functionally, it's similar > to extracting the first character using the Left$ > function, but Asc is considerably faster: > If Asc(Text) = 32 Then ' Test whether the fist char > is a space. > If Left$(Text, 1) = " " Then ' Same effect, but 2 to > 3 times slower > > When you're using the Asc function, you should > ensure that the string isn't empty because in that > case the function raises an error. In a sense, Chr$ > is the opposite of Asc in that it transforms a > numeric code into the corresponding character: > Print Chr$(65) ' Displays "A" > > The Space$ and String$ functions are very similar. > The former returns a string of spaces of the length > you want, and the latter returns a string that > consists of the character specified in the second > parameter repeated as many times as you indicated in > the first parameter: > Print Space$(5) ' Displays " " (five spaces) > Print String$(5, " ") ' Same effect > Print String$(5, 32) ' Same effect, using the char > code > Print String$(50, ".") ' A row of 50 dots > > Finally the StrComp function lets you compare > strings in a case-insensitive fashion and returns > -1, 0, or 1 if the first argument is less than, > equal to, or greater than the second argument. The > third argument specifies whether the comparison > should be performed in a case-insensitive way: > Select Case StrComp(first, second, vbTextCompare) > Case 0 > ' first = second (e.g. "VISUAL BASIC" vs. "Visual > Basic") > Case -1 > ' first < second (e.g. "C++" vs. "Visual Basic") > Case 1 > ' first > second (e.g. "Visual Basic" vs. "Delphi") > End Select > > The StrComp function is sometimes convenient even > for case-sensitive comparisons because you don't > need two separate tests to decide whether a string > is less than, equal to, or greater than another one. > Conversion Functions > The most frequently used functions for converting > strings are UCase$ and LCase$, which transform their > arguments to uppercase and lowercase, respectively: > Text = "New York, USA" > Print UCase$(Text) ' "NEW YORK, USA" > === message truncated === ________________________________________________________ Kunjungi halaman depan Yahoo! Indonesia yang baru! http://id.yahoo.com/
