We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

[69] String Functions

Last post 01-14-2007 5:00 PM by KöllMorgan. 24 replies.
Page 1 of 2 (25 items) 1 2 Next >
Sort Posts: Previous Next
  • 01-01-1999 12:00 AM

    [69] String Functions

    This thread is for discussions of String Functions.

    • Post Points: 80
  • 01-03-2002 8:54 AM In reply to

    • jaandres
    • Not Ranked
    • Joined on 12-20-2001
    • New Member
    • Points 60

    Mid function and UCase

    Hi

    I  need some help making the first character in a word large.
    I have a date, monday 23 july 2001.
    I need for det 'm' i monday to be large.

    This is my date function:
    strDate = Now()
    intDay = Day(strDate)
    strWeekDayName = WeekDayName(WeekDay(strDate))
    intThisMonth = MonthName(Month(strDate))
    intYear = Year(strDate)

    I have tried using mid function and ucase, but I keep getting smal characters og just the furst charachter in the month.

    Jannike
    • Post Points: 0
  • 01-03-2002 2:41 PM In reply to

    • mikef
    • Not Ranked
    • Joined on 01-03-2002
    • New Member
    • Points 5
    To convert the first letter of each word to upper case, use the StrConv function:
    Dim strText as String
    strText = "monday 24 july 2001"
    strText = StrConv(strText,vbProperCase)

    this will return "Monday 24 July 2001"
    • Post Points: 0
  • 04-01-2002 1:47 PM In reply to

    split

    is there a funtion that splits a string into an array by a certain character?

    Say if i had

    the|boy|is|evil

    and if i split it by "|" it would put "the" into array_whatever(0)


    n/m i got it...

         Option Explicit
         Public Function Split(ByVal sIn As String, Optional sDelim As _
               String, Optional nLimit As Long = -1, Optional bCompare As _
                VbCompareMethod = vbBinaryCompare) As Variant
             Dim sRead As String, sOut() As String, nC As Integer
             If sDelim = "" Then
                 Split = sIn
             End If
             sRead = ReadUntil(sIn, sDelim, bCompare)
             Do
                 ReDim Preserve sOut(nC)
                 sOut(nC) = sRead
                 nC = nC + 1
                 If nLimit <> -1 And nC >= nLimit Then Exit Do
                 sRead = ReadUntil(sIn, sDelim)
             Loop While sRead <> ""
             ReDim Preserve sOut(nC)
             sOut(nC) = sIn
             Split = sOut
         End Function
    • Post Points: 0
  • 04-01-2002 2:35 PM In reply to

    • Smile005
    • Top 10 Contributor
    • Joined on 06-17-2001
    • United States
    • Guru
    • Points 5,575

    VB Plug-ins?

    Is it possible to create 'plug-ins' for a vb app?
    It would be handy to be able to release 'add-ons' to programs i am making - for example - If new formats were released it would be handy to be able to have an add-in that upgrades the program?
    Any ideas?

    Thanks


    [1]Beer-==-==---==-=--=-==-===--===-=-=-====----===--=--==-====-==---==-==-=-==-===--==[/b][/1]
    [2]"No trees were destroyed in the creation of this site, however, a significant number of electrons were terribly inconvenienced."

    Beer- [black]Smile005[/black] :) ([orange]Nexus005@yahoo.co.uk[/orange])[/b][/2][1]
    Chat by MSN: [/1]BeerNexus005@yahoo.co.uk[/b][/1],
    My new site: Beer[orange]Marc Pritchard[/orange][/b],
    My joke site: Beer[orange]www.rofljokes.co.uk[/orange][/b]
    • Post Points: 0
  • 04-10-2002 8:34 AM In reply to

    • Rollershade
    • Top 10 Contributor
    • Joined on 01-10-2002
    • United Kingdom
    • Guru
    • Points 20,375

    split emmmmmm

    Say if i had

    the|boy|is|evil

    exactly wat i need to break up, into string 1,2,3,4 by the|????
    • Post Points: 0
  • 05-26-2002 5:04 AM In reply to

    Use the bit of code below.  Just replace the msgbox with the rel. storage code.
    ======================

       Dim Orig_Text As String
       Dim Orig_Tx_Len As Byte
       Dim Rem_Text As String
       Dim Rem_Tx_Len As Byte
       Dim Delim_Pos As Byte
       Dim Word_Text As String
       
       
       Orig_Text = "the|boy|is|evil"
       Orig_Tx_Len = Len(Orig_Text)
       
       Rem_Text = Orig_Text
       
       While Not Rem_Tx_Len = Orig_Tx_Len
       
       
           If InStr(1, Rem_Text, "|") > 0 Then
               
               Delim_Pos = InStr(1, Rem_Text, "|") - 1
               Word_Text = Left(Rem_Text, Delim_Pos)
               Rem_Text = Right(Rem_Text, Len(Rem_Text) - Len(Word_Text) - 1)
             
           Else
               
               Word_Text = Rem_Text
               Rem_Tx_Len = Orig_Tx_Len
                       
           End If
       
       MsgBox (Word_Text)
       
       
       Wend
    ======================
    • Post Points: 0
  • 05-26-2002 6:35 AM In reply to

    im not sure if this will get what you want but heres something different useing the Split function:

    Dim strText as string
    dim sResult1 as string, sResult2 as string, result3 as string, res4 as string

    strtext= "the|boy|is|evll" "
    sResult1 = Split(strtext, "|")(0)
    sResult2 = Split(strtext, "|")(1)
    Result3 = Split(strtext, "|")(2)
    res4= Split(strtext, "|")(3)

    Hope that helps!

    Good Luck!


    Digitally Yours,

    Thushan Fernando
    • Post Points: 0
  • 08-19-2002 9:21 PM In reply to

    • bash123
    • Not Ranked
    • Joined on 08-19-2002
    • New Member
    • Points 5

    Thanks

    Exactly what I was looking for, Thanks
    • Post Points: 0
  • 08-19-2002 9:37 PM In reply to

    is it normal to forget to notice you posted here and come back a few months later thinking wtf?

    have fun with what you just found...
    Digitally Yours,

    Thushan Fernando
    • Post Points: 0
  • 02-27-2003 2:44 PM In reply to

    • chill
    • Not Ranked
    • Joined on 02-27-2003
    • New Member
    • Points 5
    But if you have VB6 then there's already a builtin-function called split().
    It's very easy to use:
    Code:
    arrayWithSplittedData = Split(variableToSplit, "|")


    /Chill
    • Post Points: 0
  • 04-10-2003 11:16 PM In reply to

    I was thinking the same. I'm making an editor for some games and would like it if users could just hack up some simple code and have my program run it to add support for other things, but I haven't a clue how I would do it.
    • Post Points: 0
  • 04-10-2003 11:19 PM In reply to

    String to number

    How would I go about converting a number in a string to a Long value? Even more so, a hex number in a string?
    • Post Points: 0
  • 04-11-2003 12:11 PM In reply to

    • Smile005
    • Top 10 Contributor
    • Joined on 06-17-2001
    • United States
    • Guru
    • Points 5,575
    I can hardly remember this post!
    1 Apr 2002 02:35 PM
    more than a year ago. lol

    Ne way
    i've learned a bit more since then and the key to your questions is this function:
    CallByName
    Yep, it does exactly what it says on the tin. Calls any function by it's name, which might not sound any good since you can call functions in VB. BUT, You could load code into a string and call it by line using the split function:

    Dim strData()   as string
    Dim varArgs()  as string
    Dim i               as long
    Dim strText      as string

    strData = Split(strText, vbCrLf)
    For i = 0 to uBound(strData)
     'Execute
     CallByName(FunctionClass, Left$(strData(i), vbMethod, varArgs)
    Next i

    That should do it, but you'll want to work on the variable coding to actually get them from the loaded code and not supply blank ones.
    I haven't tested it so i've no idea if it'l work, but i'll run thru it ne way.
    The variables are declared first (duh)
    Then strData is sized (internally by the split command)
    The split command then splits strText by the 'Carridge Return & Line Feed' (vbCrLf) and fills each split string into a seperate index of the variable (in order of course)
    Then we start a for loop through the entire array
    Each run we call the specified function (in the FunctionClass which will be a safe class with only the externally accessable variables and no real OOP)
    Then the loop continues.
    Im sure you can work in that. A tip is to use functions to create variables (actually have an array of a user-type with a name string and a variant variable)
    Anything you don't understand post back here


    Hope it helps!


    [1]Beer-==-==---==-=--=-==-===--===-=-=-====----===--=--==-====-==---==-==-=-==-===--==[/b][/1]
    [2]"No trees were destroyed in the creation of this site, however, a significant number of electrons were terribly inconvenienced."

    Beer- [black]Smile005[/black] :) ([orange]Nexus005@yahoo.co.uk[/orange])[/b][/2][1]
    Chat by MSN: [/1]BeerNexus005@yahoo.co.uk[/b][/1],
    My new site: Beer[orange]Marc Pritchard[/orange][/b],
    My joke site: Beer[orange]www.rofljokes.co.uk[/orange][/b]
    • Post Points: 0
  • 04-14-2003 1:14 PM In reply to

    • jawsper
    • Not Ranked
    • Joined on 04-11-2003
    • Junior Member
    • Points 25

    Re: String to number

    You can use the val function:
    long=Val(string)
    ----------------------------------
    so, why arent you reading my extremely interesting post above? ;)
    • Post Points: 0
Page 1 of 2 (25 items) 1 2 Next >