|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
VB6 and SPLITIs there anyway to force the VB6 Split function to return an Integer
array rather then a String array? "JoeBananas" <Some***@aplace.net> wrote in message Nope (not that I know of anyway)... a function that converts the array is news:mkgu91pao5sr33qs58jes8iptpd7jfskfh@4ax.com... > Is there anyway to force the VB6 Split function to return an Integer > array rather then a String array? pretty simple. Wouldn't want to run this 1000's of times or anything, but for the occasional Split, it should be fine. '================= Option Explicit Private Sub Form_Load() Dim s As String Dim x As Integer Dim i() As Integer s = "1,2,3,4,5" i = SplitToInt(s) For x = 0 To UBound(i) Debug.Print i(x) Next End Sub Private Function SplitToInt(ByVal Arg As String, Optional ByVal Delim As String = ",") As Integer() Dim vTmp As Variant Dim i As Integer Dim iRet() As Integer vTmp = Split(Arg, Delim) ReDim iRet(UBound(vTmp)) For i = 0 To UBound(vTmp) iRet(i) = vTmp(i) Next SplitToInt = iRet End Function '================= -- Ken Halter - MS-MVP-VB - http://www.vbsight.com DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm Please keep all discussions in the groups.. Hi Ken !
Did you know you can use a String array to receive the Split() result instead of a Variant ? ;O) Show quoteHide quote > Dim sTmp() As String > sTmp = Split(Arg, Delim) -- Best Regards Yanick "Zoury" <yanick_lefebvre at hotmail dot com> wrote in message That one, I knew <g> How about creating a copy of an entire array with news:uSRgX%235ZFHA.4040@TK2MSFTNGP14.phx.gbl... > Hi Ken ! > > Did you know you can use a String array to receive the Split() result > instead of a Variant ? ;O) > >> Dim sTmp() As String >> sTmp = Split(Arg, Delim) > > -- > Best Regards > Yanick ThisArrayVar = ThatArrayVar? Kinda' obvious but may come in handy.... '========== Private Sub Form_Load() Dim s1() As String Dim s2() As String Dim i1() As Integer Dim i2() As Integer s1 = Split("1,2,3,4", ",") s2 = s1 s1(0) = "French" 'just to show that it's a copy and not a reference... s2(0) = "Frys" Debug.Print UBound(s2), s1(0), s2(0) 'Shows 3 French Frys ReDim i1(3) i1(0) = 0 i1(1) = 1 i1(2) = 2 i1(3) = 3 i2 = i1 Debug.Print UBound(i2) 'shows 3 (as it should) End Sub '========== Pretty cool (VB rules!) -- Ken Halter - MS-MVP-VB - http://www.vbsight.com DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm Please keep all discussions in the groups..
Code to INVERT image in VB6
How to find 3rd tuesday of the month Stopping windows from shutting down simple but not clicking now Privileges and killing a process How do you code Asynchronous MP3 playing with VB6/API? setting exit code of VB app Monitoring a software installation..... Tabulating document proerties from a folder in Access Sorting a 2d array by more than 1 column |
|||||||||||||||||||||||