Results 1 to 4 of 4

Thread: VB Textbox to Excel [Resolved]

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    33

    Resolved 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.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: VB Textbox to Excel

    You just need to parse out the data using Instr & Mid$ string functions.
    VB Code:
    1. Dim iStart as integer
    2. dim iEnd as integer
    3. dim sData as string
    4. dim iData() as integer
    5. istart = instr(1, Text1.text, "==>print freqvalue")
    6. if istart > 0 then 'found
    7.     iend = instr(istart + 1, Text1.text, "==>")
    8.     sdata = mid$(Text1.text, istart, iend - istart)
    9.     idata = split(sdata, ",")
    10.     'Loop though the array of integers adding to excel
    11.     '...
    12.     '...
    13. else
    14.     msgbox "data not found"
    15. 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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    33

    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:
    1. Dim strRaw As String
    2.     Dim strStartKey As String
    3.     Dim i As Integer
    4.     Dim r As Integer
    5.     Dim Numbers As Variant
    6.     strRaw = TextBox1.Text
    7.     strStartKey = "==>print freqvalue"
    8.     strRaw = Right(strRaw, Len(strRaw) - InStr(1, strRaw, strStartKey, vbTextCompare) _
    9.         - Len(strStartKey) - 1) 'Minus another 1 for CR/LF
    10.     Numbers = Split(strRaw, Chr(13), -1, vbTextCompare)
    11.     r = 0
    12.     For i = 0 To UBound(Numbers)
    13.       If IsNumeric(Numbers(i)) Then
    14.         r = r + 1
    15.         Cells(r, 1).Value = Int(Numbers(i))
    16.       End If
    17.     Next i

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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
  •  



Click Here to Expand Forum to Full Width