Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

remove a letter or number

kralskrals Posts: 57Member
Hi,
lets say i have the following word: Hello
SO when i press a button i want to remove the "o" and if i press it again to remove the "l" ctr..

i think i must use a function...but i dont know which and how.

thanks.
«1

Comments

  • BitByBit_ThorBitByBit_Thor Posts: 2,444Member
    : Hi,
    : lets say i have the following word: Hello
    : SO when i press a button i want to remove the "o" and if i press it
    : again to remove the "l" ctr..
    :
    : i think i must use a function...but i dont know which and how.
    :
    : thanks.

    Use Left$, Mid$ and Right$ to take portions of the string.
    Basically, removing a character at position n (where position 1 is the first character) means: Left$(s, n - 1) & Mid$(s, n + 1). This is taking the part before the character-to-be-removed, and the part after and pasting them back together.

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • lionblionb Posts: 1,688Member ✭✭
    : : Hi,
    : : lets say i have the following word: Hello
    : : SO when i press a button i want to remove the "o" and if i press it
    : : again to remove the "l" ctr..
    : :
    : : i think i must use a function...but i dont know which and how.
    : :
    : : thanks.
    :
    : Use Left$, Mid$ and Right$ to take portions of the string.
    : Basically, removing a character at position n (where position 1 is
    : the first character) means: Left$(s, n - 1) & Mid$(s, n + 1). This
    : is taking the part before the character-to-be-removed, and the part
    : after and pasting them back together.
    :
    : Best Regards,
    : Richard
    :
    : The way I see it... Well, it's all pretty blurry
    :
    IMHO it will be better idea to use Replace() and InStr() functions.

    Replace([italic]Expession as String,Find as String,Replace as String,[Start as Long = 1],[Count as Long = 1][/italic]) As String

    InStr([[b]Start[/b]],[[italic]String1[/italic]],[[italic]String2[/italic]]) As Long

    Something like that

    [code]
    Dim strSelText As String

    If InStr(Text1, "o") > 0 Then
    strSelText = "o"
    Text1 = Replace(Text1.Text, strSelText, "", 1)
    Else
    If InStr(Text1, "e") > 0 Then
    strSelText = "e"
    Text1 = Replace(Text1.Text, strSelText, "", 1)
    End If
    End If[/code]
    Or this code
    [code]
    Private Sub Command1_Click()

    Dim strSelText As String
    strSelText = Right(Text1, 1) 'select last letter
    Text1 = Replace(Text1.Text, strSelText, "", 1, 1)
    End Sub
    [/code]
    Of course it's just an idea and you have to modify it according to your needs
  • BitByBit_ThorBitByBit_Thor Posts: 2,444Member
    :
    : IMHO it will be better idea to use Replace() and InStr() functions.
    :

    Only if you want to replace a specific character.
    Depending on whether you have the position or the character, you should use Left/Mid, respectively Replace. InStr can be used to find the position of the character, but is useless if you're already using replace. If you have the position, you could use Mid$ to get the character, but this is also useless because you'd then be able to use Left/Mid.

    So, conclusion: depending on what you know, you should either use Left/Mid or Replace. In speed, I doubt that Replace is at all faster (though it is possible that the developer team optimized replace).

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • kralskrals Posts: 57Member
    : :
    : : IMHO it will be better idea to use Replace() and InStr() functions.
    : :
    :
    : Only if you want to replace a specific character.
    : Depending on whether you have the position or the character, you
    : should use Left/Mid, respectively Replace. InStr can be used to find
    : the position of the character, but is useless if you're already
    : using replace. If you have the position, you could use Mid$ to get
    : the character, but this is also useless because you'd then be able
    : to use Left/Mid.
    :
    : So, conclusion: depending on what you know, you should either use
    : Left/Mid or Replace. In speed, I doubt that Replace is at all faster
    : (though it is possible that the developer team optimized replace).
    :
    : Best Regards,
    : Richard
    :
    : The way I see it... Well, it's all pretty blurry


    Thank you very much to all of you.
    Your solutions helped me a lot!
  • lionblionb Posts: 1,688Member ✭✭
    [color=Blue]So, conclusion: depending on what you know, ...[/color]
    I like your conclusion :-)
    Personally, I am not big user of InStr() function and just tried to show krals how different VB string functions and/or their combinations could be used.
  • lionblionb Posts: 1,688Member ✭✭
    : Thank you very much to all of you.
    : Your solutions helped me a lot!
    :
    You are welcome
  • kralskrals Posts: 57Member
    ok guys, one last question:

    I have made a package (in order to install it properly to another pc),so when i run the setup to the other pc i get message:"setup cannot continue because some system files are of date on your system.Click if you would like setup to update these files for you now.You will need to restart Windows before you run the setup again".I press ok,i restart pc but i get the same message even doing the restart.
    I have to say that i just setup this PC with windows,so no updates are installed.

    Is there any solution for this? or i have to make a windows update?
  • lionblionb Posts: 1,688Member ✭✭
    : ok guys, one last question:
    :
    : I have made a package (in order to install it properly to another
    : pc),so when i run the setup to the other pc i get message:"setup
    : cannot continue because some system files are of date on your
    : system.Click if you would like setup to update these files for you
    : now.You will need to restart Windows before you run the setup
    : again".I press ok,i restart pc but i get the same message even doing
    : the restart.
    : I have to say that i just setup this PC with windows,so no updates
    : are installed.
    :
    : Is there any solution for this? or i have to make a windows update?
    :
    Yeah ... I remember this stupid problem but do not remember how to fix it. There are some system files in your package whoes versions are older than one on your new machine. I think you have to install Visual Studio SP6 on machine where Application and Package were created then rebild package. Try following link (copy and paste it to the address bar)

    http://support.microsoft.com/default.aspx?scid=kb;EN-US;192461

  • kralskrals Posts: 57Member
    Ok,i fixed it like this:
    I installed from VB6 cd-rom only the ActiveX Controls and Database tools (ADO,DAO ctr).I tried to run setup again but i got the same error again.
    So i just copied the .exe file and run it.
    Everything works fine except one thing: I have a calendar control which is used to save a date,so when i press the button to save it i get:
    "Run time error: -2147352560 (80020010)

    Automation error
    invalid callee"

    (i have posted this problem some days before..a similar problem)



  • dokken2dokken2 Posts: 532Member
    : Ok,i fixed it like this:
    : I installed from VB6 cd-rom only the ActiveX Controls and Database
    : tools (ADO,DAO ctr).I tried to run setup again but i got the same
    : error again.
    : So i just copied the .exe file and run it.
    : Everything works fine except one thing: I have a calendar control
    : which is used to save a date,so when i press the button to save it i
    : get:
    : "Run time error: -2147352560 (80020010)
    :
    : Automation error
    : invalid callee"
    :
    : (i have posted this problem some days before..a similar problem)
    :
    :
    :
    :

    here's a work around i used on an install that kept asking to "need to update system files."

    compare the file date/version of the [Bootstrap Files] list in "setup.lst" file [see below] to what exists on the target pc.
    delete any file from the [Bootstrap Files] list when the target pc has a *newer* file version than the one in the vb6 setup.lst file

    [recall receiving an error message during install but the EXE now runs on the problem pc]


    [Bootstrap Files]
    File1=@vb6stkit.dll,$(WinSysPathSysFile),,,3/26/99 12:00:00 AM,101888,6.0.84.50
    File2=@COMCAT.DLL,$(WinSysPathSysFile),$(DLLSelfRegister),,5/31/98 12:00:00 AM,22288,4.71.1460.1
    File3=@stdole2.tlb,$(WinSysPathSysFile),$(TLBRegister),,8/23/01 8:00:00 AM,17920,3.50.5014.0
    File4=@asycfilt.dll,$(WinSysPathSysFile),,,8/4/04 12:56:42 AM,65024,5.1.2600.2180
    File5=@olepro32.dll,$(WinSysPathSysFile),$(DLLSelfRegister),,8/4/04 12:56:46 AM,83456,5.1.2600.2180
    File6=@oleaut32.dll,$(WinSysPathSysFile),$(DLLSelfRegister),,8/4/04 12:56:46 AM,553472,5.1.2600.2180
    File7=@msvbvm60.dll,$(WinSysPathSysFile),$(DLLSelfRegister),,2/23/04 8:42:40 PM,1386496,6.0.97.82


«1
Sign In or Register to comment.