|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
2 pieces of the same code doing different thingsPublic Sub ImRec(ByVal IM As IAccIm, ByVal Sender As IAccUser) Dim str As String = IM.GetConvertedText(DECODE) Dim temp As String = str temp = temp.Remove(temp.IndexOf("<body>"), 6) temp = temp.Remove(temp.IndexOf("</body>"), 7) Me.webRecv.DocumentText += "<br>" & str End Sub and Private Sub s_OnImReceived(ByVal session As AccCoreLib.AccSession, ByVal imSession As AccCoreLib.IAccImSession, ByVal sender As AccCoreLib.IAccParticipant, ByVal im As AccCoreLib.IAccIm) Handles s.OnImReceived Dim str As String = im.GetConvertedText(decode) str = str.Remove(str.IndexOf("<body>"), 6) str = str.Remove(str.IndexOf("</body>"), 7) Me.webrecv.DocumentText += "<br>" & str End Sub the bottom snippet works, the top one doesnt. the only thing different is that the bottom one works directly in the event while the other snippet works from a method called from that event.....all my objects and variables have a value, these values are correct (after debugging it under every surcumstance imaginable) i cant get the top snippet to work. im just curious why two pieces of the same code dont work the same.....im using VB 2005 btw....ive contacted the manufacturer of the SDK this is in to see if its a problem there, so im also asking here to see if its something with my code.....shouldnt these two snippets work the same? what am i missing? thanks -- -iwdu15 in the first one you are not using temp:
Me.webRecv.DocumentText += "<br>" & temp -tom iwdu15 ha scritto: Show quoteHide quote > hi, i have these 2 code snippets: > > Public Sub ImRec(ByVal IM As IAccIm, ByVal Sender As IAccUser) > > Dim str As String = IM.GetConvertedText(DECODE) > > Dim temp As String = str > > temp = temp.Remove(temp.IndexOf("<body>"), 6) > temp = temp.Remove(temp.IndexOf("</body>"), 7) > > Me.webRecv.DocumentText += "<br>" & str > > End Sub > > and > > Private Sub s_OnImReceived(ByVal session As AccCoreLib.AccSession, ByVal > imSession As AccCoreLib.IAccImSession, ByVal sender As > AccCoreLib.IAccParticipant, ByVal im As AccCoreLib.IAccIm) Handles > s.OnImReceived > > Dim str As String = im.GetConvertedText(decode) > > str = str.Remove(str.IndexOf("<body>"), 6) > str = str.Remove(str.IndexOf("</body>"), 7) > > Me.webrecv.DocumentText += "<br>" & str > > End Sub > > > the bottom snippet works, the top one doesnt. the only thing different is > that the bottom one works directly in the event while the other snippet works > from a method called from that event.....all my objects and variables have a > value, these values are correct (after debugging it under every surcumstance > imaginable) i cant get the top snippet to work. im just curious why two > pieces of the same code dont work the same.....im using VB 2005 btw....ive > contacted the manufacturer of the SDK this is in to see if its a problem > there, so im also asking here to see if its something with my > code.....shouldnt these two snippets work the same? what am i missing? thanks > > -- > -iwdu15 Your last line of code in the first piece:
Me.webRecv.DocumentText += "<br>" & str Shouldn't you be using "temp"? You haven't done anything with "str". Tom iwdu15 wrote: Show quoteHide quote >hi, i have these 2 code snippets: > > Public Sub ImRec(ByVal IM As IAccIm, ByVal Sender As IAccUser) > > Dim str As String = IM.GetConvertedText(DECODE) > > Dim temp As String = str > > temp = temp.Remove(temp.IndexOf("<body>"), 6) > temp = temp.Remove(temp.IndexOf("</body>"), 7) > > Me.webRecv.DocumentText += "<br>" & str > > End Sub > >and > > Private Sub s_OnImReceived(ByVal session As AccCoreLib.AccSession, ByVal >imSession As AccCoreLib.IAccImSession, ByVal sender As >AccCoreLib.IAccParticipant, ByVal im As AccCoreLib.IAccIm) Handles >s.OnImReceived > > Dim str As String = im.GetConvertedText(decode) > > str = str.Remove(str.IndexOf("<body>"), 6) > str = str.Remove(str.IndexOf("</body>"), 7) > > Me.webrecv.DocumentText += "<br>" & str > > End Sub > > >the bottom snippet works, the top one doesnt. the only thing different is >that the bottom one works directly in the event while the other snippet works >from a method called from that event.....all my objects and variables have a >value, these values are correct (after debugging it under every surcumstance >imaginable) i cant get the top snippet to work. im just curious why two >pieces of the same code dont work the same.....im using VB 2005 btw....ive >contacted the manufacturer of the SDK this is in to see if its a problem >there, so im also asking here to see if its something with my >code.....shouldnt these two snippets work the same? what am i missing? thanks > > > well in the second one i am creating a copy of the variable str and putting
it into temp. this is because later i will add code to manipulate temp and i want to keep the original. the first one i wasnt planning on doing that. i have tried it without using the temp variable and it does the same thing -- -iwdu15 Hmmmm.
as it has been pointed out, the 2 snipptes are not the same. In the first you apply the 2 remove calls to 'temp' but appent 'str'. In the second, you apply the 2 remove calls to 'str' and append 'str'. Maybe this is just a typo in the explanation (example) in which case it might help if you were to explain in detail what 'doesn't work' means. -- Show quoteHide quoteTerry "iwdu15" wrote: > well in the second one i am creating a copy of the variable str and putting > it into temp. this is because later i will add code to manipulate temp and i > want to keep the original. the first one i wasnt planning on doing that. i > have tried it without using the temp variable and it does the same thing > -- > -iwdu15 sure, il explain. the first snippet is from one app where an event calls the
method, passing in all needed variables. i create an exact copy of the variable which contains the text i want to add to the WebBrowser document. Later i will add code to add in a username and Time received to the Temporary variable, this is why i do that. So now i have two variables which are exactly trhe same, str and temp. i remove the "<body>" tags so the text will line up with the left side of the WebBrowser control and not be floating around the middle. then i attempt to add the text to the WebBrowser. occaisionally it will add the very first thing i pass it, but after that nothing. The html is correct, i have triple checked it. what ends up almost always happening is when it hits this line: Me.webRecv.DocumentText += "<br>" & str in the first code snippet, it goes over it like it does the code, but the text is never added to the webbrowser. no error, nothing. I have changed it to Me.webRecv.DocumentText += "<br>" & temp but still nothing. now to the second snippet. the second snippet is in a different application (and yes i have tried putting my code in a new project, i have also tried completely recoding my project but the first part of code still doesnt work). in this app, the code is added directly from the event that is raised. the HTML code is exactly the same as the first code snippets, but this time it is added to the WebBrowser perfectly fine. The text shows up exactly how its supposed to. in the first snippet, i am creating a copy and removing the body tags then attempting to add it and it doesnt work, in the second one i cut the body tags out of the first variable and add it to the WebBrowser and it works perfectly. Would this be an issue? hope this makes a little more sense now....thanks for your help -- -iwdu15 Place a break on the line
Me.webRecv.DocumentText += "<br>" & temp to see if it is executed at all. -t iwdu15 ha scritto: Show quoteHide quote > sure, il explain. the first snippet is from one app where an event calls the > method, passing in all needed variables. i create an exact copy of the > variable which contains the text i want to add to the WebBrowser document. > Later i will add code to add in a username and Time received to the Temporary > variable, this is why i do that. So now i have two variables which are > exactly trhe same, str and temp. i remove the "<body>" tags so the text will > line up with the left side of the WebBrowser control and not be floating > around the middle. then i attempt to add the text to the WebBrowser. > occaisionally it will add the very first thing i pass it, but after that > nothing. The html is correct, i have triple checked it. what ends up almost > always happening is when it hits this line: > > Me.webRecv.DocumentText += "<br>" & str > > in the first code snippet, it goes over it like it does the code, but the > text is never added to the webbrowser. no error, nothing. I have changed it > to > > Me.webRecv.DocumentText += "<br>" & temp > > but still nothing. now to the second snippet. > > the second snippet is in a different application (and yes i have tried > putting my code in a new project, i have also tried completely recoding my > project but the first part of code still doesnt work). in this app, the code > is added directly from the event that is raised. the HTML code is exactly the > same as the first code snippets, but this time it is added to the WebBrowser > perfectly fine. The text shows up exactly how its supposed to. > > in the first snippet, i am creating a copy and removing the body tags then > attempting to add it and it doesnt work, in the second one i cut the body > tags out of the first variable and add it to the WebBrowser and it works > perfectly. Would this be an issue? hope this makes a little more sense > now....thanks for your help > -- > -iwdu15 it is executed, all variables have values, all variables have correct
values....everything should work but it doesnt -- -iwdu15 Ok, lets back up for a minute. Do both methods work when placed directly in
the event? Do both methods fail when placed in a called sub? -- Show quoteHide quoteTerry "iwdu15" wrote: > it is executed, all variables have values, all variables have correct > values....everything should work but it doesnt > -- > -iwdu15 no, the first one still does not work when placed in the event and the second
snippet still works when placed in a separate method and called from the event -- -iwdu15 Well you got me stumped! Is option strict on? I think that if I was you, I
would use ILDASM for the two snippits and see if I could spot what was happening. -- Show quoteHide quoteTerry "iwdu15" wrote: > no, the first one still does not work when placed in the event and the second > snippet still works when placed in a separate method and called from the event > -- > -iwdu15 ILDASM is the IL DisASseMbler. It shows the IL code emitted by the
compiler. Can you post a short but complete sample that demonstrates the problem? iwdu15 wrote: Show quoteHide quote > whats ILDASM? how would this help with my....unusual problem? > -- > -iwdu15 my first post has everything thats involved in this....il try to fully
explain my situation.. im creating an AIM Custom Client using the SDK that AOL kindly provided. When an IM is received, the event OnImReceived is fired. In one app (which is very very basic) handles the IM and and enters the text into the WebBrowser control (the AIM network formats text in an HTML like formatting, so i figured this control would be best). this works fine, the text is added with no difficulty. However, in my more complete application, the IM is received in the same event in the same exact way. however, instead of beign added to a control right away, the object is passed to the form that shows the Instant Messages. this form then passes this same variable to a user control i made. the object is not changed or even accessed in any way until it reaches my custom control, where then my first snippet method is called. hope this helps understand whats going on i have copied and pasted the code form the working one to the not working one and it still wont work....i have no idea whats going on here.....when i get home il check the ILDASM stuff, but (Chris and anyone that was wondering) i hope this helps in some way.... -- -iwdu15 heres the ILDASM for setting the text
Broken App: IL_00cc: callvirt instance class [System.Windows.Forms]System.Windows.Forms.WebBrowser AimCC.ctrlIM::get_webRecv() IL_00d1: stloc.s VB$t_ref$S0 IL_00d3: ldloc.s VB$t_ref$S0 IL_00d5: ldloc.s VB$t_ref$S0 IL_00d7: callvirt instance string [System.Windows.Forms]System.Windows.Forms.WebBrowser::get_DocumentText() IL_00dc: ldstr "<br>" IL_00e1: ldloc.0 IL_00e2: call string [mscorlib]System.String::Concat(string, string, string) IL_00e7: callvirt instance void [System.Windows.Forms]System.Windows.Forms.WebBrowser::set_DocumentText(string) working app: IL_0054: callvirt instance class [System.Windows.Forms]System.Windows.Forms.WebBrowser WindowsApplication1.Form1::get_webrecv() IL_0059: stloc.1 IL_005a: ldloc.1 IL_005b: ldloc.1 IL_005c: callvirt instance string [System.Windows.Forms]System.Windows.Forms.WebBrowser::get_DocumentText() IL_0061: ldstr "<br>" IL_0066: ldloc.0 IL_0067: call string [mscorlib]System.String::Concat(string, string, string) IL_006c: callvirt instance void [System.Windows.Forms]System.Windows.Forms.WebBrowser::set_DocumentText(string) the only difference seems to be this: IL_00d1: stloc.s VB$t_ref$S0 IL_00d3: ldloc.s VB$t_ref$S0 IL_00d5: ldloc.s VB$t_ref$S0 any ideas? -- -iwdu15 iwdu15 wrote:
> my first post has everything thats involved in this....il try to fully Yes, but your first post has a bug:> explain my situation.. > > Public Sub ImRec(ByVal IM As IAccIm, ByVal Sender As IAccUser) Here you get a string> > Dim str As String = IM.GetConvertedText(DECODE) > You assign the string to a temp variable> Dim temp As String = str > > temp = temp.Remove(temp.IndexOf("<body>"), 6) You manipulate the temp variable...> temp = temp.Remove(temp.IndexOf("</body>"), 7) > > Me.webRecv.DocumentText += "<br>" & str But then you assign the original string back to DocumentText!! You> > End Sub should assign the temp variable back like this: Me.webRecv.DocumentText += "<br>" & temp
Custom Attributes, Shared methods, Derived classes and reflection
allowing just numeric value in my textbox *** HELP *** Problems Accessing Simple VB.NET Access Database Multi-Threaded App Cross-thread operation not valid How to validate Date entries. Wanted: Simple VB.NET "WEB" Application with an Access Database String translation Saving an image from the browser Positioning Other Applicaitons |
|||||||||||||||||||||||