|
-
Jun 14th, 2006, 06:45 PM
#41
PowerPoster
Re: How to read each line from multiline textbox?
Even if we saw the project we probably couldn't help much as we couldn't send him the fixed version unless we had VB5 ourselves. I think we've given him the answer he needs to fix it though, so hopefully he'll make the changes and resolve/rate :-)
Edit: Maybe not...split function is fine in module1, but if the code you posted is in the main form adding the form name won't make a difference...there must be something else causing the issue
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
Jun 14th, 2006, 06:46 PM
#42
Thread Starter
Addicted Member
Re: How to read each line from multiline textbox?
Form1
VB Code:
Private Sub Command1_Click()
Dim strArray() As String
strArray = Split(txtText, vbCrLf)
Text1.Text = strArray(0)
Text2.Text = strArray(1)
Text3.Text = strArray(2)
End Sub
Module1
VB Code:
Public Function Split(ByVal sIn As String, _
Optional sDelim As String = " ", _
Optional nLimit As Long = -1, _
Optional bCompare As VbCompareMethod = vbBinaryCompare) _
As Variant
Dim nC As Long, nPos As Long, nDelimLen As Long
Dim sOut() As String
If sDelim <> "" Then
nDelimLen = Len(sDelim)
nPos = InStr(1, sIn, sDelim, bCompare)
Do While nPos
ReDim Preserve sOut(nC)
sOut(nC) = Left(sIn, nPos - 1)
sIn = Mid(sIn, nPos + nDelimLen)
nC = nC + 1
If nLimit <> -1 And nC >= nLimit Then Exit Do
nPos = InStr(1, sIn, sDelim, bCompare)
Loop
End If
ReDim Preserve sOut(nC)
sOut(nC) = sIn
Split = sOut
End Function
-
Jun 14th, 2006, 06:49 PM
#43
PowerPoster
Re: How to read each line from multiline textbox?
When you run the code and it crashes, can you find out what line it crashes at? I've never used VB5 but in VB6, it gives you the option to debug which will show you the line where the error is
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
Jun 14th, 2006, 06:53 PM
#44
Re: How to read each line from multiline textbox?
You need to place error handling in your Split function as if it errors code execution will be thrown back to the calling procedure - Command1_Click().
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 14th, 2006, 06:55 PM
#45
Thread Starter
Addicted Member
Re: How to read each line from multiline textbox?
it highlights the following
strArray =
and gives me the error "Can't assign to array"
-
Jun 14th, 2006, 06:57 PM
#46
PowerPoster
Re: How to read each line from multiline textbox?
Tell you what, here's what I'll do....I'll write a custom function you can use instead of using split...it's a simple matter to do a little parsing. I'll edit this post with it if no-one replies :-)
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
Jun 14th, 2006, 06:59 PM
#47
Re: How to read each line from multiline textbox?
The error could be because in the Split function your second argument is a string whereas vbCrLF is a combination of these two characters Chr$(13)+Chr$(10).
Change it to this...
VB Code:
strArray = Split(txtText, "vbCrLf")
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 14th, 2006, 07:01 PM
#48
PowerPoster
Re: How to read each line from multiline textbox?
 Originally Posted by RobDog888
Change it to this...
Tell me if that works...if not, I'll code the function :-)
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
Jun 14th, 2006, 07:03 PM
#49
Re: How to read each line from multiline textbox?
Actually I dont think it will work still as it gets evaluated later in the procedure.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 14th, 2006, 07:07 PM
#50
Thread Starter
Addicted Member
Re: How to read each line from multiline textbox?
no it doesn't work.....same error
thanks smUX
edit:
thanks to all you guys for helping :-)
Last edited by rdcody; Jun 14th, 2006 at 07:10 PM.
-
Jun 14th, 2006, 07:16 PM
#51
PowerPoster
Re: How to read each line from multiline textbox?
This code relies on instr() and mid() and this is my test code as before with modifications...took a bit of tweaking but it works. Hopefully other people will read and comment on a better way to do it in VB5 or perhaps point out stuff that could be changed/tweaked :-)
VB Code:
Private Sub Command1_Click()
Dim strArray() As String, startof(2) As Single, endof(2) As Single
startof(0) = 1: endof(0) = InStr(1, txtText, vbCrLf)
startof(1) = endof(0) + 2: endof(1) = InStr(startof(1), txtText, vbCrLf)
startof(2) = endof(1) + 2: endof(2) = InStr(startof(2), txtText, vbCrLf)
Text1.Text = Mid(txtText, startof(0), endof(0) - startof(0))
Text2.Text = Mid(txtText, startof(1), endof(1) - startof(1))
Text3.Text = Mid(txtText, startof(2), Len(txtText) - startof(2) + 1)
End Sub
Private Sub Form_Load()
txtText = "a" & vbCrLf & "b" & vbCrLf & "c"
End Sub
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
Jun 14th, 2006, 07:30 PM
#52
Thread Starter
Addicted Member
Re: How to read each line from multiline textbox?
Hey thanks smUX.....that works!
-
Jun 14th, 2006, 07:31 PM
#53
PowerPoster
Re: (Resolved) How to read each line from multiline textbox?
Last edited by RobDog888; Jun 14th, 2006 at 08:00 PM.
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
Jun 15th, 2006, 08:37 AM
#54
Thread Starter
Addicted Member
Re: (Resolved) How to read each line from multiline textbox?
Hey smUX,
You ought to post this code in the codebank.....both versions VB5, and VB6,
and maybe how to load the multiline textbox from the textboxes.
VB Code:
txtText = Text1.Text & vbCrLf & Text2.Text & vbCrLf & _
Text3.Text & vbCrLf & Text4.Text
Thanks again,
Ron
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|