Invisible Characters?-VBForums
Results 1 to 25 of 25

Thread: Invisible Characters?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2009
    Posts
    358

    Invisible Characters?

    I'm making a program that changes a word then adds it to a listbox, the only problem is, when I change the word, I don't want the change to be noticeable, are their any invisible characters?
    Sorry if my posts are misleading or sometimes rude, I'm just trying to get information so try to help me out.

  2. #2
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,274

    Re: Invisible Characters?

    There are characters that don't have a visual representation in text, but I really don't get what you are after here...
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  3. #3
    vb Coda .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    19,099

    Re: Invisible Characters?

    you want a display word + a corresponding hidden word?

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2009
    Posts
    358

    Re: Invisible Characters?

    Quote Originally Posted by kleinma View Post
    There are characters that don't have a visual representation in text, but I really don't get what you are after here...
    If the word that is being changed is "Word" then when the word is changed with the invisible character, it will look like "Word" . Basically I don't want the word to have any visual change.
    Sorry if my posts are misleading or sometimes rude, I'm just trying to get information so try to help me out.

  5. #5
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,274

    Re: Invisible Characters?

    again, I still don't get what you are after here. Not at all.

    If you want to have some hidden value associated with a given string, then make a structure with 2 members, and override ToString to emit the actual string member you want for display purposes, while leaving the other one to be this edited version you want.

    This is only a guess as to a solution, since I have no idea at all what it is you are actually trying to accomplish.
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2009
    Posts
    358

    Re: Invisible Characters?

    Quote Originally Posted by kleinma View Post
    again, I still don't get what you are after here. Not at all.

    If you want to have some hidden value associated with a given string, then make a structure with 2 members, and override ToString to emit the actual string member you want for display purposes, while leaving the other one to be this edited version you want.

    This is only a guess as to a solution, since I have no idea at all what it is you are actually trying to accomplish.
    There will be 2 list boxes, one with the word to be replaced, the other with what it will be replaced with, but the user will not see the words be replaced at all, when the user presses a button it will replace all of the words in the listbox with the corresponding index in the other listbox. So, if you put "Word" in listbox one and "Words" is placed in listbox 2, then when the user presses a button, it will change only the one instance of "Word" that they chose to "Words"
    Does that make sense?
    Sorry if my posts are misleading or sometimes rude, I'm just trying to get information so try to help me out.

  7. #7
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,274

    Re: Invisible Characters?

    not really to be honest.

    It probably doesn't help that the string you picked to use is "word". just makes reading it more confusing.


    So there are 2 listboxes, listbox1 has "HELLO" selected in it. listbox2 has "WORLD" selected in it. User clicks a button, and listbox2's text should change to be "HELLO", except it should not actually change in the UI, and continue to say "WORLD". Is that what you are asking for?
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2009
    Posts
    358

    Re: Invisible Characters?

    Quote Originally Posted by kleinma View Post
    not really to be honest.

    It probably doesn't help that the string you picked to use is "word". just makes reading it more confusing.


    So there are 2 listboxes, listbox1 has "HELLO" selected in it. listbox2 has "WORLD" selected in it. User clicks a button, and listbox2's text should change to be "HELLO", except it should not actually change in the UI, and continue to say "WORLD". Is that what you are asking for?
    I forgot to mention that the words being replaced would be in a textbox.
    Example:
    Code:
    textbox1.replace(listbox1.item(1),listbox2.item(1))
    See what I mean? I know how to do this, but if the contents of the text box are:

    The word word in this sentence will be replaced with words.

    So it would look like this:

    The word words in this sentence will be replaced with words.

    in the previous example, listbox1.item(1) was word, listbox2.item(1) was words
    Sorry if my posts are misleading or sometimes rude, I'm just trying to get information so try to help me out.

  9. #9
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,274

    Re: Invisible Characters?

    Quote Originally Posted by CoBHC View Post

    The word word in this sentence will be replaced with words.

    and how is it supposed to decide if it should replace the blue "word" or the red "word" in that sentence?
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  10. #10
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Sector 001
    Posts
    1,579

    Re: Invisible Characters?

    He probably wants to use a listbox as a container and change something but this change should not be obvious.
    VB 2005, Win Xp Pro sp2

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2009
    Posts
    358

    Re: Invisible Characters?

    Quote Originally Posted by kleinma View Post
    and how is it supposed to decide if it should replace the blue "word" or the red "word" in that sentence?
    That is why I need characters that aren't visible. So "word" when changed with the new characters length would be 5 instead of 4 but it would still look like "word"
    Sorry if my posts are misleading or sometimes rude, I'm just trying to get information so try to help me out.

  12. #12
    Addicted Member
    Join Date
    Apr 2009
    Location
    Near Dog River (sorta)
    Posts
    160

    Re: Invisible Characters?

    I used a "hidden" character when I wrote some C64 software...

    IIRC, ASCII character 255 looks like a space, but obviously is saved differently since it is not ASCII character 32 (the spacebar space).

    So, you could append Chr(255) to the end of each word, or if users are suspicious of words that have "a space" after them, have every word before the change to *really* have Chr(32) after it. Then, change the last character of that word to Chr(255).
    Last edited by JugglingReferee; May 29th, 2009 at 03:39 PM.
    PC #1: Athlon64 X2+Vista64+VS2008EE+.NET3.5 #2: XP (all flavours Ghost'd)+VS2008EE+.NET3.5
    Help Files: HelpMaker Dr. Explain Create Icons: IcoFX


    "Whoever eats my flesh and drinks my blood has eternal life, and I will raise him on the last day." John 6:54

  13. #13
    Addicted Member
    Join Date
    Apr 2009
    Location
    Near Dog River (sorta)
    Posts
    160

    Re: Invisible Characters?

    Or, could you use the tag property to determine if a word has been changed?

    For the ListBox control with 8 entries, the tag property will be 8 characters long. The nth character is a 0 if unaltered, and 1 if altered.
    PC #1: Athlon64 X2+Vista64+VS2008EE+.NET3.5 #2: XP (all flavours Ghost'd)+VS2008EE+.NET3.5
    Help Files: HelpMaker Dr. Explain Create Icons: IcoFX


    "Whoever eats my flesh and drinks my blood has eternal life, and I will raise him on the last day." John 6:54

  14. #14
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,274

    Re: Invisible Characters?

    Quote Originally Posted by JugglingReferee View Post
    I used a "hidden" character when I wrote some C64 software...

    IIRC, ASCII character 255 looks like a space, but obviously is saved differently since it is not ASCII character 32 (the spacebar space).

    So, you could append ASC(255) to the end of each word, or if users are suspicious of words that have "a space" after them, have every word before the change to *really* have ASC(32) after it. Then, change the last character of that word to ASC(255).
    ASC returns an integer based on a passed in char. I think you probably mean Chr() to get a character from its numeric ASCII value.

    Either way, I don't think this will work. Usually these characters will just show up as square blocks in the UI.
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  15. #15
    Addicted Member
    Join Date
    Apr 2009
    Location
    Near Dog River (sorta)
    Posts
    160

    Re: Invisible Characters?

    Of course you are correct, kleinma. I meant to say Chr().

    I will edit the post.
    PC #1: Athlon64 X2+Vista64+VS2008EE+.NET3.5 #2: XP (all flavours Ghost'd)+VS2008EE+.NET3.5
    Help Files: HelpMaker Dr. Explain Create Icons: IcoFX


    "Whoever eats my flesh and drinks my blood has eternal life, and I will raise him on the last day." John 6:54

  16. #16
    vb Coda .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    19,099

    Re: Invisible Characters?

    or just use a custom listItem:

    vb Code:
    1. Public Class listItem
    2.  
    3.     Public displayString As String
    4.     Public hiddenString As String
    5.  
    6.     Public Sub New(ByVal _displayString As String, ByVal _hiddenString As String)
    7.         displayString = _displayString
    8.         hiddenString = _hiddenString
    9.     End Sub
    10.  
    11.     Public Overrides Function ToString() As String
    12.         Return displayString
    13.     End Function
    14.  
    15. End Class

    vb Code:
    1. ListBox1.Items.Add(New listItem("this is the display string", "this is the hidden string"))

    to retrieve the hidden string:

    vb Code:
    1. MsgBox(DirectCast(ListBox1.SelectedItem, listItem).hiddenString)

  17. #17
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,274

    Re: Invisible Characters?

    Quote Originally Posted by .paul. View Post
    or just use a custom listItem:

    vb Code:
    1. Public Class listItem
    2.  
    3.     Public displayString As String
    4.     Public hiddenString As String
    5.  
    6.     Public Sub New(ByVal _displayString As String, ByVal _hiddenString As String)
    7.         displayString = _displayString
    8.         hiddenString = _hiddenString
    9.     End Sub
    10.  
    11.     Public Overrides Function ToString() As String
    12.         Return displayString
    13.     End Function
    14.  
    15. End Class

    vb Code:
    1. ListBox1.Items.Add(New listItem("this is the display string", "this is the hidden string"))

    to retrieve the hidden string:

    vb Code:
    1. MsgBox(DirectCast(ListBox1.SelectedItem, listItem).hiddenString)
    That was my original suggestion, but the more he described the app, the more confusing it sounded, and the less viable that seemed to be a solution.
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  18. #18

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2009
    Posts
    358

    Re: Invisible Characters?

    Quote Originally Posted by JugglingReferee View Post
    Or, could you use the tag property to determine if a word has been changed?

    For the ListBox control with 8 entries, the tag property will be 8 characters long. The nth character is a 0 if unaltered, and 1 if altered.
    I'm not replacing the items in the listbox. I'm replacing the text in the textbox with items from the listbox.
    Sorry if my posts are misleading or sometimes rude, I'm just trying to get information so try to help me out.

  19. #19
    vb Coda .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    19,099

    Re: Invisible Characters?

    Quote Originally Posted by kleinma View Post
    That was my original suggestion, but the more he described the app, the more confusing it sounded, and the less viable that seemed to be a solution.
    thats what i was thinking of in post #3 + IMO its still the most sensible solution

  20. #20
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,274

    Re: Invisible Characters?

    You may be right, but I am still unsure of the exact intent here to be honest.
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  21. #21

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2009
    Posts
    358

    Re: Invisible Characters?

    Quote Originally Posted by kleinma View Post
    You may be right, but I am still unsure of the exact intent here to be honest.
    if * was an invisble character, and I added it to "word" word would still look like this"word" and if it was not an invisible character, word would look like this "word*" I don't want it to add extra spaces either, I want the textboxes contents to look exactly the same when a word is added to the listbox, and changed.
    Sorry if my posts are misleading or sometimes rude, I'm just trying to get information so try to help me out.

  22. #22
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,274

    Re: Invisible Characters?

    You can't. So you need to come up with a different approach. Like caching the string that is "real" in a variable and always displaying the original string you WANT the user to see. There isn't a way to "fake" the computer out in thinking a string is x length when it is really y length. It just doesn't work that way, and it doesn't need to. You just need to implement things differently.
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  23. #23

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2009
    Posts
    358

    Re: Invisible Characters?

    Quote Originally Posted by kleinma View Post
    You can't. So you need to come up with a different approach. Like caching the string that is "real" in a variable and always displaying the original string you WANT the user to see. There isn't a way to "fake" the computer out in thinking a string is x length when it is really y length. It just doesn't work that way, and it doesn't need to. You just need to implement things differently.
    I'm not trying to make the computer think it's a different length, I'm trying to get the computer to not see a character.
    Sorry if my posts are misleading or sometimes rude, I'm just trying to get information so try to help me out.

  24. #24
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Re: Invisible Characters?

    Keep a class-level variable called RealString, and use it when you want to access the data. Update it when the contents of the TextBox change. When you want to access the length or the data, use it.

  25. #25
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Re: Invisible Characters?

    Perhaps telling us what the point in doing this is would help us to help you.

    Give us an example of what you want your program to do.

    If you don't want characters to come up then just declare an extra variable to hold the word you want hidden and store the word you want to show up in the textbox.
    If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved!

    If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job

    __________________
    My Vb.Net CodeBank Submissions:
    Microsoft Calculator Clone
    Custom TextBox Restrictions
    Get the Text inbetween HTML Tags (or two words)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.