From: Dennis Rose on
I have a VB5 program into which I have loaded vbSendMail(written in VB6). I
need to replace the "Split" instruction,
" sFilenames = Split(.filename, vbNullChar)", in the following code:

Private Sub cmdBrowse_Click()

Dim sFilenames() As String
Dim i As Integer

On Local Error GoTo Err_Cancel

With cmDialog
.filename = ""
.CancelError = True
.Filter = "All Files (*.*)|*.*|HTML Files
(*.htm;*.html;*.shtml)|*.htm;*.html;*.shtml|Images
(*.bmp;*.jpg;*.gif)|*.bmp;*.jpg;*.gif"
.FilterIndex = 1
.DialogTitle = "Select File Attachment(s)"
.MaxFileSize = &H7FFF
.Flags = &H4 Or &H800 Or &H40000 Or &H200 Or &H80000
.ShowOpen
' get the selected name(s)
sFilenames = Split(.filename, vbNullChar)
End With

What VB5 code can I use??

Thanks for your help!!
From: Paul Clement on
On Wed, 3 Feb 2010 13:17:02 -0800, Dennis Rose <DennisRose(a)discussions.microsoft.com> wrote:

� I have a VB5 program into which I have loaded vbSendMail(written in VB6). I
� need to replace the "Split" instruction,

One of the links below should help:

http://support.microsoft.com/kb/188007
http://www.vb-helper.com/howto_vb5_split_join.html


Paul
~~~~
Microsoft MVP (Visual Basic)
From: Helmut Meukel on

"Dennis Rose" <DennisRose(a)discussions.microsoft.com> schrieb im Newsbeitrag
news:BD37FF9B-DD91-4A72-A6EC-A1A0AEF88D28(a)microsoft.com...
>I have a VB5 program into which I have loaded vbSendMail(written in VB6).
>I
> need to replace the "Split" instruction,
> " sFilenames = Split(.filename, vbNullChar)", in the following code:
>
-----<snip>-----

Dennis,

in 2002 I wrote a Split for VB5, using internal Pat Steiner's
BreakString2Parts

HTH,

Helmut.

Here is the code:
(Some comments are in German, Sorry)

'***********************************************************
'* Procedure Name: Split *
'*---------------------------------------------------------*
'* Created: 28.10.2001 By: HM-Soft Hof, Helmut Meukel *
'* Modified: 24.03.2002 By: HM-Soft Hof, Helmut Meukel *
'*=========================================================*
'* Nachbildung der ab VB6 verfügbaren Split Funktion *
'* March 2002: added support for multicharacter delimiters *
'***********************************************************
Public Function Split(ByVal expression As String, _
Optional ByVal delimiter As String = " ", _
Optional ByVal limit As Long = -1, _
Optional ByVal compare As VbCompareMethod _
= vbBinaryCompare) As Variant
Attribute Split.VB_Description = "Returns a zero-based, one-dimensional
array containing a specified number of substrings."

Dim Splits() As String, l As Long, fDelimiterFound As Boolean
Dim sPart1 As String, sPart2 As String

'versuchen wir das Verhalten von VB6-Split in Grenzfällen
' nachzubauen (noch nicht getestet, nur nach Beschreibung
' in VB6 Online Help):
' [was ist wenn 1) und 2) zugleich zutreffen?]
'1) expression = ""
If Len(expression) = 0 Then
Split = Splits()
'2) delimiter = ""
ElseIf Len(delimiter) = 0 Then
ReDim Splits(0)
Splits(0) = expression
Split = Splits()
'3) limit = 0 [wie VB6-Split hier reagiert steht nicht
' in Online Help]
ElseIf limit = 0 Then
Split = Splits()
Else 'Normalfall
l = -1
Do
fDelimiterFound = BreakString2Parts(expression, delimiter, sPart1,
sPart2)
If Len(sPart1) > 0 Then
l = l + 1
If l Mod 100 = 0 Then ReDim Preserve Splits(l + 100)
Splits(l) = sPart1
End If
expression = sPart2
Loop While fDelimiterFound
ReDim Preserve Splits(l)
Split = Splits()
End If

End Function


Public Function BreakString2Parts(ByVal sText As String, ByVal _
sDelimiter As String, sPart1 As String, _
sPart2 As String) As Boolean
'------------------------------------------------------------------
' Purpose: Break the input string [sText] into 2 parts
' ([sPart1] and [sPart2]) looking for the special
' delimiter character(s) [sDelimiter].
'
' Note: If no delimiter character is found in the input string,
' the function will still return [sPart1] and [sPart2],
' but the return value of the function will be False (0)
' instead of True (-1).
'-------------------------------------------------------------------
' Version: 1.0 2.0
' By: Pat Steiner Helmut Meukel, HM - Soft Hof
' Date: 10/1/97 2002-03-01
'-------------------------------------------------------------------
' HM: Das ist eine schöne Routine. Ab VB6 ist sie aber weitgehend
' obsolet, Split liefert die Teilstrings schön abgepackt
' in einem Stringarray!
' Um auch für VB6 noch interessant zu sein fehlt ein optionaler
' Parameter [Start], mit dem man eine Mindestgröße für [sPart1]
' definieren könnte.
'-------------------------------------------------------------------
' HM-Soft's Routine Split für VB5 verwendet intern BreakString2Parts
' Deshalb ab Version 2.0 aufgebohrt für Multi-Character Delimiters
' und interne Variable geändert auf long für sehr lange Strings.
'-------------------------------------------------------------------
Dim sMessage As String
Dim sMsgTitle As String ' = ""
'Dim sFunction As String
Dim iMessage As Integer ' = 0
'Dim iError As Integer
Dim iLen As Long
Dim iStart As Long
Dim iDelimiter As Long
Dim lenDeli As Integer
Dim iChars As Long

'------------------------------------------------------------
' Initialize "local" variables
'------------------------------------------------------------
BreakString2Parts = False 'Initial function value = False
sPart1 = ""
sPart2 = ""

On Error GoTo Err_BreakString2Parts 'Setup error handler

'------------------------------------------------------------
' Look for function "input" errors (calling argument errors)
'------------------------------------------------------------
lenDeli = Len(sDelimiter)
If lenDeli = 0 Then
'no delimiter, no breacking
GoTo Exit_BreakString2Parts
End If

'------------------------------------------------------------
' Parse the string and separate into 2 parts ...
' check "small" inputs strings first.
'------------------------------------------------------------
iLen = Len(sText)

If iLen < 1 Then 'String not worth parsing!!!
GoTo Exit_BreakString2Parts
End If

If iLen <= lenDeli Then
If sDelimiter <> sText Then
'short string <> delimiter ... set it = [sPart1]
sPart1 = sText
End If
GoTo Exit_BreakString2Parts
ElseIf iLen < 2 * lenDeli Then
If Left$(sText, lenDeli) = sDelimiter Then
'starts with delimiter ... Tail to [sPart2]
sPart2 = Mid$(sText, lenDeli + 1)
BreakString2Parts = True
GoTo Exit_BreakString2Parts
End If
End If

'------------------------------------------------------------
' Parse the string and separate into 2 parts
'------------------------------------------------------------
iDelimiter = 0
'Set the position of the delimiter = 1st occurrence of it!!!
iDelimiter = InStr(sText, sDelimiter)

If iDelimiter = 0 Then
'longer string (no delimiter) ... set it = [sPart1]
sPart1 = sText
GoTo Exit_BreakString2Parts
End If

If iDelimiter = 1 Then
'longer string (starts with delimiter) ... set it = [sPart2]
sPart2 = Mid$(sText, lenDeli + 1)
BreakString2Parts = True
GoTo Exit_BreakString2Parts
End If

'String is delimited as anticipated ... set [sPart1]
iChars = iDelimiter - 1
sPart1 = Left$(sText, iChars)

iStart = iDelimiter + lenDeli
'String is delimited as anticipated ... set [sPart2]
sPart2 = Mid$(sText, iStart)

BreakString2Parts = True

'======================
Exit_BreakString2Parts:
'======================
Exit Function

'=====================
Err_BreakString2Parts:
'=====================
sMessage = "Error #" & Err & ": " & Error(Err)
MsgBox sMessage, iMessage, sMsgTitle
Exit Function

End Function

From: Bob Butler on

"Dennis Rose" <DennisRose(a)discussions.microsoft.com> wrote in message
news:BD37FF9B-DD91-4A72-A6EC-A1A0AEF88D28(a)microsoft.com...
>I have a VB5 program into which I have loaded vbSendMail(written in VB6).
>I
> need to replace the "Split" instruction,
> " sFilenames = Split(.filename, vbNullChar)", in the following code:
<cut>
> What VB5 code can I use??

http://www.lmgtfy.com/?q=vb5+split+function

From: Karl E. Peterson on
Bob Butler wrote:
>> What VB5 code can I use??
>
> http://www.lmgtfy.com/?q=vb5+split+function

This answer has my vote!

--
..NET: It's About Trust!
http://vfred.mvps.org