Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Insert datetime.now via code snippet comment block
Message
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
Miscellaneous
Thread ID:
01311174
Message ID:
01311262
Views:
13
Thanks, Paul. Yeah, I'm getting the impression intellisense ain't gonna do it, but I have learned some cool stuff about macros. I've figured out how to create the macro to do what I want
    Sub InsertCRH()
        Dim textSelection As EnvDTE.TextSelection

        textSelection = CType(DTE.ActiveDocument.Selection(), EnvDTE.TextSelection)
        textSelection.Text = "' CRH: " & System.DateTime.Now.ToString() & CrLf _
        & "' "

    End Sub
and how to drag that onto the toolbar for easy access. By adding CRH as a tasklist token i can now find all my own comments I insert into code easily.

And while messing around with that I put the CommentRegion() macro on the toolbar and then wrote an Uncomment macro
  Sub UncommentBlock()
        Dim current As String
        current = DTE.ActiveDocument.Name

        DTE.ExecuteCommand("Edit.Find")
        DTE.ExecuteCommand("Edit.SwitchtoQuickReplace")
        DTE.ExecuteCommand("Edit.SelectAll")
        DTE.Windows.Item(current).Activate()

        DTE.Find.FindWhat = "'"
        DTE.Find.ReplaceWith = ""
        DTE.Find.Target = vsFindTarget.vsFindTargetCurrentDocumentSelection
        DTE.Find.MatchCase = False
        DTE.Find.MatchWholeWord = False
        DTE.Find.MatchInHiddenText = True
        DTE.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxLiteral
        DTE.Find.ResultsLocation = vsFindResultsLocation.vsFindResultsNone
        DTE.Find.Action = vsFindAction.vsFindActionReplaceAll
        If (DTE.Find.Execute() = vsFindResult.vsFindResultNotFound) Then
            Throw New System.Exception("vsFindResultNotFound")
        End If
        DTE.Windows.Item("{CF2DDC32-8CAD-11D2-9302-005345000000}").Close()
    End Sub
as I couldn't find an equivalent in VB 2008 for what we've had in VFP.

Love the VS IDE but can see there is still room for improvement <g>



>>I am having fun with the VB code snippet editor. i want to be able to insert a comment block with my initials and current datetime and don't seem to have the magic formula. Have this in CEE but trying to figure it out in VB
>>
>>'CRH: Wednesday 03/16/08
>>' Insert comment here
>>'
>
>I could be wrong, but I don't think code snippets support this kind of thing - you'd have to do this as a macro (at least, that's my foggy memory of things since I wanted to do something very similar).
>
>I ended up using Coderush/Refactor! from DevExpress and writing a very simple plug-in for it. Actually Coderush can be downloaded for free (just without all of the extras). If you decide to go this route, let me know. You're welcome to this code/plug in.

I'll check out the DevExpress thing you referenced and let you know.

Thanks again


Charles Hankey

Though a good deal is too strange to be believed, nothing is too strange to have happened.
- Thomas Hardy

Half the harm that is done in this world is due to people who want to feel important. They don't mean to do harm-- but the harm does not interest them. Or they do not see it, or they justify it because they are absorbed in the endless struggle to think well of themselves.

-- T. S. Eliot
Democracy is two wolves and a sheep voting on what to have for lunch.
Liberty is a well-armed sheep contesting the vote.
- Ben Franklin

Pardon him, Theodotus. He is a barbarian, and thinks that the customs of his tribe and island are the laws of nature.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform