My Contribution To Welcome in 2017
My Contribution To Welcome in 2017
My Contribution To Welcome in 2017
My Contribution To Welcome in 2017
My Contribution To Welcome in 2017
My Contribution To Welcome in 2017 My Contribution To Welcome in 2017 My Contribution To Welcome in 2017 My Contribution To Welcome in 2017 My Contribution To Welcome in 2017 My Contribution To Welcome in 2017 My Contribution To Welcome in 2017 My Contribution To Welcome in 2017
My Contribution To Welcome in 2017 My Contribution To Welcome in 2017
My Contribution To Welcome in 2017
Go Back  Xtreme Visual Basic Talk > > > > My Contribution To Welcome in 2017


Reply
 
Thread Tools Display Modes
  #1  
Old 01-11-2017, 06:44 AM
zunebuggy zunebuggy is offline
Newcomer
 
Join Date: Sep 2010
Posts: 22
Smile My Contribution To Welcome in 2017


Hello,

I have not posted in awhile and it is usually to ask HOW to do something. I thought I'd share a small utility I wrote in VBA for Excel that works well for my uses. Maybe it will be useful to someone here.

Please let me know if you find it useful. You could modify it for your own needs and if you do please post your modded code. I would like to see it.

To use this:

Open a New Excel spreadsheet
In cell A1 type Comment: and make B1 a longer width and maybe put a bold border around it and/or shade it.

Now simply paste the following VBA code:

Code:
Public MyTextString As String
Sub Perfect_Memo_Writer()
    Open "C:\Users\jonas.barber\Desktop\memo_text.txt" For Output As #1
        Print #1, "'" & vbCrLf & "'#######################################################"
        MyTextEntry = Range("B1")
        myTextArry = Split(MyTextEntry, " ", , vbTextCompare)
        LenFirstWord = Len(myTextArry(0))
        If LenFirstWord > 50 Then
            MsgBox "Riduculously long words not allowed!"
            Exit Sub
        Else
            MyTextString = myTextArry(0)
        End If
        For m = 1 To UBound(myTextArry)
            cmpWords = MyTextString & " " & myTextArry(m)
            If Len(cmpWords) > 51 Then
                WriteTheMiddle
                MyTextString = myTextArry(m)
            Else
                MyTextString = MyTextString & " " & myTextArry(m)
            End If
        Next m
        WriteTheMiddle
        Print #1, "'#######################################################"
    Close #1
        
End Sub
Sub WriteTheMiddle()
                MemoLen = 26.5
                TextLen = Len(MyTextString) / 2
                If Len(MyTextString) / 2 = Int(Len(MyTextString) / 2) Then
                    bb = " "
                Else
                    bb = ""
                End If
                startCol = (MemoLen - TextLen)
                For k = 1 To startCol
                    aa = aa & " "
                Next k
                Print #1, "'#" & aa & MyTextString & aa & bb & "#"
End Sub
To use it, simply type a comment into B1 of any length and run the Perfect_Memo_Writer(). Go to your Desktop and open the memo_text.txt file and select all and copy and paste the comment into your code for sharp, consistent comments that stand out.
Reply With Quote
  #2  
Old 01-11-2017, 07:09 AM
zunebuggy zunebuggy is offline
Newcomer
 
Join Date: Sep 2010
Posts: 22
Default

Code:
'
'#######################################################
'#   This is an example of what my automatic comment   #
'# creator does.  It generates VB comments that stand  #
'#    out and are perfectly centered no matter the     #
'#                   length. Enjoy!                    #
'#######################################################
Reply With Quote
Reply

Tags
mytextstring, code, mytextarrym, writethemiddle, comment, print, paste, perfect_memo_writer, simply, type, textlen, lenfirstword, memolen, vba, lenmytextstring, excel, startcol, mytextentry, select, file, memo_text.txt, desktop, lenmytextarry0, vbtextcompare, splitmytextentry


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
My Contribution To Welcome in 2017
My Contribution To Welcome in 2017
My Contribution To Welcome in 2017 My Contribution To Welcome in 2017
My Contribution To Welcome in 2017
My Contribution To Welcome in 2017
My Contribution To Welcome in 2017 My Contribution To Welcome in 2017 My Contribution To Welcome in 2017 My Contribution To Welcome in 2017 My Contribution To Welcome in 2017 My Contribution To Welcome in 2017 My Contribution To Welcome in 2017
My Contribution To Welcome in 2017
My Contribution To Welcome in 2017
 
My Contribution To Welcome in 2017
My Contribution To Welcome in 2017
 
-->