且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

字符串替换/注册表操作

更新时间:2023-11-14 15:01:58

尝试使用Replace函数。


将reg值加载到mystring中

替换( mystring,autoStart ="& chr(34)&" 0" chr(34)," autoStart ="&

chr(34)&" ; 1"& chr(34))

将mystring写回reg
Try to use the Replace function.

load reg value into mystring
Replace(mystring, "autoStart=" & chr(34) & "0" & chr(34), "autoStart=" &
chr(34) & "1" & chr(34))
write mystring back to reg


感谢您的回复。我考虑过这样做,但我也在考虑这个问题:


s ="< root formID =" preferencesform"郎= QUOT;英语&QUOT; >< global welcome =" 0"

lang =" british" soundEffects = QUOT; 0&QUOT; soundTheme = QUOT;默认&QUOT; stayOnTop =" 0"

autoStart =" 0" />< main>< pos x =" 761" Y =&QUOT; 277&QUOT; />< size width =" 240"

height =" 450" />< / main>< chat fontFamily =" tahoma" fontSize =" 12"

inMsgColor =" 255" outMsgColor = QUOT; 3368448&QUOT; />< video

webcam =" undefined" />< / root>"


Dim i As Integer = s.IndexOf (autoStart)''i =''a''自动启动

Dim ss As String = s.Substring(i + 11,1).Replace(" 0"," 1")


然后再次整理整个字符串,但是在上面的示例中,'s''在上面的'b'中保留了compulete字符串,现在它开始了只包含''1''


那么,如何将它写回整个字符串?


任何想法?
Thanks for your reply. I thought about doing that, but I was also thinking
on the lines of this:

s = "<root formID="preferencesform" lang="english" ><global welcome="0"
lang="british" soundEffects="0" soundTheme="default" stayOnTop="0"
autoStart="0" /><main ><pos x="761" y="277" /><size width="240"
height="450" /></main><chat fontFamily="tahoma" fontSize="12"
inMsgColor="255" outMsgColor="3368448" /><video
webcam="undefined"/></root>"

Dim i As Integer = s.IndexOf("autoStart") '' i = ''a'' of autostart
Dim ss As String = s.Substring(i + 11, 1).Replace("0", "1")

Then concatinating the entire string again, but whereas ''s'' in the example
above held the compulete string at the beginning now it contains just ''1''

So, how to I write it back to the entire string?

Any ideas?


我认为你会发现在执行这两个语句之后,那个s / $
仍然保持while字符串(未更改)并且ss的长度为1和

值为1。


您是否尝试过简单:


s = s。替换(autoStart ="" 0"""," autoStart ="" 1"")


我也不喜欢我真的明白你对使用XmlDocument的抵制,比如

这个:


Dim _doc为新的XmlDocument

_doc.LoadXml( s)

_doc.SelectSingleNode(" // global")。Attributes(" autoStart")。Value =" 1"

_s = _doc.OuterXml

" Newbie Coder" < ne ********* @ spammeplease.com写信息

新闻:%2 **************** @ TK2MSFTNGP03.phx .gbl ...
I think that you will find that after executing those 2 statements, that s
still holds the while string (unchanged) and that ss has a length of 1 and a
value of "1".

Have you tried simply:

s = s.Replace("autoStart=""0""", "autoStart=""1"")

Also I don''t really understand your resistance to using an XmlDocument like
this:

Dim _doc as New XmlDocument
_doc.LoadXml(s)
_doc.SelectSingleNode("//global").Attributes("autoStart").Value = "1"
_s = _doc.OuterXml
"Newbie Coder" <ne*********@spammeplease.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...

感谢您的回复。我考虑过这样做,但我也在考虑这个问题:


s ="< root formID =" preferencesform"郎= QUOT;英语&QUOT; >< global welcome =" 0"

lang =" british" soundEffects = QUOT; 0&QUOT; soundTheme = QUOT;默认&QUOT; stayOnTop =" 0"

autoStart =" 0" />< main>< pos x =" 761" Y =&QUOT; 277&QUOT; />< size width =" 240"

height =" 450" />< / main>< chat fontFamily =" tahoma" fontSize =" 12"

inMsgColor =" 255" outMsgColor = QUOT; 3368448&QUOT; />< video

webcam =" undefined" />< / root>"


Dim i As Integer = s.IndexOf (autoStart)''i =''a''自动启动

Dim ss As String = s.Substring(i + 11,1).Replace(" 0"," 1")


然后再次整理整个字符串,但是在上面的示例中,'s''在上面的'b'中保留了compulete字符串,现在它开始了只包含''1''


那么,如何将它写回整个字符串?


任何想法?

Thanks for your reply. I thought about doing that, but I was also thinking
on the lines of this:

s = "<root formID="preferencesform" lang="english" ><global welcome="0"
lang="british" soundEffects="0" soundTheme="default" stayOnTop="0"
autoStart="0" /><main ><pos x="761" y="277" /><size width="240"
height="450" /></main><chat fontFamily="tahoma" fontSize="12"
inMsgColor="255" outMsgColor="3368448" /><video
webcam="undefined"/></root>"

Dim i As Integer = s.IndexOf("autoStart") '' i = ''a'' of autostart
Dim ss As String = s.Substring(i + 11, 1).Replace("0", "1")

Then concatinating the entire string again, but whereas ''s'' in the example
above held the compulete string at the beginning now it contains just ''1''

So, how to I write it back to the entire string?

Any ideas?