|
-
May 17th, 2005, 11:57 AM
#1
Thread Starter
Member
VB Textbox to Excel [Resolved]
Hi there,
I have a textbox on my VB form which contains the following.
VM-1 Control Computer running Venom-SC
Version 2004 01 08
Copyright 2000-2004 Micro-Robotics Ltd.
Clear memory: Y/N/S ?N
-->init
-->main
==>print fs
RAM Filesystem files: (* = open)
17-05-05-0944 116
17-05-05-1215 116
17-05-05-1224 116
17-05-05-1329 44
17-05-05-1338 136
17-05-05-1347 136
17-05-05-1354 136
17-05-05-1406 136
17-05-05-1417* 156
Free space 56 blocks = 28672 bytes
==>print freqvalue
87
87
87
87
96
68
68
68
68
68
68
68
68
121
31
31
31
21
-39
60
60
60
60
60
60
60
60
60
60
60
60
60
60
60
60
-39
60
60
-139
==>
The number of integers varies each time i run the program.
What i need to do is extract the integers between the lines ==>print freqvalue and ==>.
These values must then be automatically sent to an Excel file where each integer will appear in a different cell of the first column.
I already have code which sends the entire contents of the textbox to a single cell (A1).
Can anyone help?
Last edited by royshh; May 18th, 2005 at 11:30 AM.
-
May 17th, 2005, 12:31 PM
#2
Re: VB Textbox to Excel
You just need to parse out the data using Instr & Mid$ string functions.
VB Code:
Dim iStart as integer
dim iEnd as integer
dim sData as string
dim iData() as integer
istart = instr(1, Text1.text, "==>print freqvalue")
if istart > 0 then 'found
iend = instr(istart + 1, Text1.text, "==>")
sdata = mid$(Text1.text, istart, iend - istart)
idata = split(sdata, ",")
'Loop though the array of integers adding to excel
'...
'...
else
msgbox "data not found"
endif
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 
-
May 18th, 2005, 11:27 AM
#3
Thread Starter
Member
Re: VB Textbox to Excel
I tried using your code but unfortunately it didn't work.
Thanks for your help anyway.
Someone else gave me the following code and it works perfectly.
VB Code:
Dim strRaw As String
Dim strStartKey As String
Dim i As Integer
Dim r As Integer
Dim Numbers As Variant
strRaw = TextBox1.Text
strStartKey = "==>print freqvalue"
strRaw = Right(strRaw, Len(strRaw) - InStr(1, strRaw, strStartKey, vbTextCompare) _
- Len(strStartKey) - 1) 'Minus another 1 for CR/LF
Numbers = Split(strRaw, Chr(13), -1, vbTextCompare)
r = 0
For i = 0 To UBound(Numbers)
If IsNumeric(Numbers(i)) Then
r = r + 1
Cells(r, 1).Value = Int(Numbers(i))
End If
Next i
-
May 18th, 2005, 11:42 AM
#4
Re: VB Textbox to Excel [Resolved]
Mine was an example as you could see the comments for looping and such, but glad you got it solved.
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 
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
|