Results 1 to 4 of 4

Thread: Exact Code Produces Different Results

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2009
    Posts
    78

    Exact Code Produces Different Results

    So, I have this code.

    vb Code:
    1. Case Keys.U
    2.                     With Me.TextBox1
    3.                         Dim selectionStart As Integer = .SelectionStart
    4.                         Dim selectionLength As Integer = .SelectionLength
    5.  
    6.                         .SelectedText = underline & .SelectedText & underlineend
    7.                         .SelectionStart = selectionStart + underline.Length
    8.                         .SelectionLength = selectionLength
    9.                     End With
    10.                 Case Keys.I
    11.                     With Me.TextBox1
    12.                         Dim selectionStart As Integer = .SelectionStart
    13.                         Dim selectionLength As Integer = .SelectionLength
    14.  
    15.                         .SelectedText = underline & .SelectedText & underlineend
    16.                         .SelectionStart = selectionStart + underline.Length
    17.                         .SelectionLength = selectionLength
    18.                     End With

    It is inside if e.modifiers = keys.shift and a select case e.keycode

    The code inside case keys.u is the exact same as keys.i, yet whenever I press control-i, it adds a whole bunch of spaces between the "underline" and "underlinelength" strings. So control-u produces

    vb Code:
    1. [u][/u]

    but control-i, with the exact same code, produces

    vb Code:
    1. [u]                  [/u]

    It's getting really frustrating... can someone please shed some light on this ridiculous malfunctioning?

    Urgh, and what I find EVEN MORE annoying is that if I replace e.keycode = keys.i with e.keycode = keys.p, there is no problem!
    Last edited by Raeki; Oct 15th, 2010 at 04:18 PM.

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,043

    Re: Exact Code Produces Different Results

    Have you put a breakpoint in those two cases to see what the selection length is? What I am wondering is whether the issue is within that code, or in the selectedtext. Of course, it would probably look the same, so I guess the actual comparison would be on the selectedText.Length property.
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2009
    Posts
    78

    Re: Exact Code Produces Different Results

    I found that control-i seems to put that big block of spaces in... its one big character

    Any way to cancel that? The auto-recognition like control-z is autmatic without me coding anything

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,043

    Re: Exact Code Produces Different Results

    Do you have any hotkeys defined on that computer? A big chunk of space like that sounds like a tab, or some similar thing. If you identify that, you might figure out why it is being added. Offhand, I don't know of anything. Of course, if it always happens, and the length is one higher than it should be, you might just remove that one character whenever you press that key combination.
    My usual boring signature: Nothing

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