Results 1 to 16 of 16

Thread: Enter between Lines

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2006
    Posts
    35

    Enter between Lines

    Hi Experts!!

    I am stuck please help me!

    Could you please let me know how can I insert enter between lines?

    for example

    I am storing some text in a varialble and I want after few characters rest of the characters should come in next time. Like we use \n in c and java.

    What can be used in VBA Code?

    tex="Hello how are you doing? what'up?"

    I want when i print this code in excel sheet I "What's up" should come in the next line?

    Thanks,

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

    Re: Enter between Lines

    Weel to enter in line breaks you would do this.
    VB Code:
    1. tex="Hello how are you doing?" & vbNewline & "what'up?"
    But Im just assumming that you already have the Excel part done. You may have to enable the word wrapping in Excel though.
    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
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Enter between Lines

    VB Code:
    1. tex="Hello how are you doing?[B]" & vbCrLf & "[/B]what'up?"
    2.  
    3. 'or
    4.  
    5. tex="Hello how are you doing?[B]" & vbNewLine & "[/B]what'up?"
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

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

    Re: Enter between Lines

    Beat you Static
    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

  5. #5
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Enter between Lines

    Use the vbNewLine constant.


    Edit:

  6. #6
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Enter between Lines

    Rob.. ahh.. well thats cause you took the cheap way out and did not give a thurough answer!! cheater!! lol

    penagate - No.. use the vbCrLf!!!
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  7. #7
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Enter between Lines

    Actually I believe vbNewLine is better as it is defined as a platform independent new line constant. vbCrLf is a hardcoded CR + LF sequence.

    Could be wrong though.

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

    Re: Enter between Lines

    Static: I did give the answer and c0d.

    PG: thats what happens when you use that smiley too much, you get slow

    There is no difference between vbNewLine and vbCrLf. They are the same, only up to your personal preference but vbNewLine is better
    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

  9. #9
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Enter between Lines

    yep looked in the object browser.. they are the same.. but vbCrLf just looks so much more cryptic.. that makes it better
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  10. #10
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Enter between Lines

    Quote Originally Posted by RobDog888
    There is no difference between vbNewLine and vbCrLf. They are the same, only up to your personal preference but vbNewLine is better
    How?

    Can you show an example or something?
    CS

  11. #11
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Enter between Lines

    Yeah? how is it better?




    --- still waiting!
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  12. #12
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: Enter between Lines

    In Windows they're both Chr(13) & Chr(10). If MS ports VB to *nix, vbNewLine would be Chr(10)
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

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

    Re: Enter between Lines

    Quote Originally Posted by Static
    Yeah? how is it better?
    Readibility in your code and like I posted, its a personal preference but you should all do as I say without question

    From the immediate window....

    VB Code:
    1. ?asc(mid$(vbnewline,1,1)) & " - " & asc(mid$(vbnewline,2,1))
    2. 13 - 10
    3. ?asc(mid$(vbcrlf,1,1)) & " - " & asc(mid$(vbcrlf,2,1))
    4. 13 - 10
    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

  14. #14

    Thread Starter
    Member
    Join Date
    Jun 2006
    Posts
    35

    Re: Enter between Lines

    Thanks a bunch it wouked out.

    However when I use & vbnewline it breaks the line and enters one space before the first character of next line.

    Example

    This is first line
    this is second line

    One more question. Is there any function to bold/italic the text

  15. #15
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: Enter between Lines

    Quote Originally Posted by vikasbhandari2
    However when I use & vbnewline it breaks the line and enters one space before the first character of next line.

    Example

    This is first line
    this is second line
    Make sure you're not telling it to include that space. vbNewLine has no space in it.
    One more question. Is there any function to bold/italic the text
    Not in a variable, since it wouldn't make sense - bold and italic are display properties, not properties of the text.

    If you want to display the text as bold or italic in a text box, it all has to be bold or italic (or both). If you want just some characters changed you'd have to display it in a rich text box.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  16. #16

    Thread Starter
    Member
    Join Date
    Jun 2006
    Posts
    35

    Re: Enter between Lines

    I am using Rich Text box, what options I have to make them bold.

    I want some of the words should come in bold!!

    Thanks in advance!!!

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