473,698 Members | 2,304 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

2 pieces of the same code doing different things

hi, i have these 2 code snippets:

Public Sub ImRec(ByVal IM As IAccIm, ByVal Sender As IAccUser)

Dim str As String = IM.GetConverted Text(DECODE)

Dim temp As String = str

temp = temp.Remove(tem p.IndexOf("<bod y>"), 6)
temp = temp.Remove(tem p.IndexOf("</body>"), 7)

Me.webRecv.Docu mentText += "<br>" & str

End Sub

and

Private Sub s_OnImReceived( ByVal session As AccCoreLib.AccS ession, ByVal
imSession As AccCoreLib.IAcc ImSession, ByVal sender As
AccCoreLib.IAcc Participant, ByVal im As AccCoreLib.IAcc Im) Handles
s.OnImReceived

Dim str As String = im.GetConverted Text(decode)

str = str.Remove(str. IndexOf("<body> "), 6)
str = str.Remove(str. IndexOf("</body>"), 7)

Me.webrecv.Docu mentText += "<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.....should nt these two snippets work the same? what am i missing? thanks

--
-iwdu15
Jul 31 '06 #1
15 1569
in the first one you are not using temp:

Me.webRecv.Docu mentText += "<br>" & temp
-tom

iwdu15 ha scritto:
hi, i have these 2 code snippets:

Public Sub ImRec(ByVal IM As IAccIm, ByVal Sender As IAccUser)

Dim str As String = IM.GetConverted Text(DECODE)

Dim temp As String = str

temp = temp.Remove(tem p.IndexOf("<bod y>"), 6)
temp = temp.Remove(tem p.IndexOf("</body>"), 7)

Me.webRecv.Docu mentText += "<br>" & str

End Sub

and

Private Sub s_OnImReceived( ByVal session As AccCoreLib.AccS ession, ByVal
imSession As AccCoreLib.IAcc ImSession, ByVal sender As
AccCoreLib.IAcc Participant, ByVal im As AccCoreLib.IAcc Im) Handles
s.OnImReceived

Dim str As String = im.GetConverted Text(decode)

str = str.Remove(str. IndexOf("<body> "), 6)
str = str.Remove(str. IndexOf("</body>"), 7)

Me.webrecv.Docu mentText += "<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.....should nt these two snippets work the same? what am i missing? thanks

--
-iwdu15
Jul 31 '06 #2
Your last line of code in the first piece:

Me.webRecv.Docu mentText += "<br>" & str

Shouldn't you be using "temp"? You haven't done anything with "str".

Tom
iwdu15 wrote:
>hi, i have these 2 code snippets:

Public Sub ImRec(ByVal IM As IAccIm, ByVal Sender As IAccUser)

Dim str As String = IM.GetConverted Text(DECODE)

Dim temp As String = str

temp = temp.Remove(tem p.IndexOf("<bod y>"), 6)
temp = temp.Remove(tem p.IndexOf("</body>"), 7)

Me.webRecv.Docu mentText += "<br>" & str

End Sub

and

Private Sub s_OnImReceived( ByVal session As AccCoreLib.AccS ession, ByVal
imSession As AccCoreLib.IAcc ImSession, ByVal sender As
AccCoreLib.IAc cParticipant, ByVal im As AccCoreLib.IAcc Im) Handles
s.OnImReceiv ed

Dim str As String = im.GetConverted Text(decode)

str = str.Remove(str. IndexOf("<body> "), 6)
str = str.Remove(str. IndexOf("</body>"), 7)

Me.webrecv.Docu mentText += "<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.....shoul dnt these two snippets work the same? what am i missing? thanks
Jul 31 '06 #3
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
Jul 31 '06 #4
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.
--
Terry
"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
Jul 31 '06 #5
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.Docu mentText += "<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.Docu mentText += "<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
Jul 31 '06 #6
Place a break on the line

Me.webRecv.Docu mentText += "<br>" & temp

to see if it is executed at all.

-t
iwdu15 ha scritto:
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.Docu mentText += "<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.Docu mentText += "<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
Jul 31 '06 #7
it is executed, all variables have values, all variables have correct
values....every thing should work but it doesnt
--
-iwdu15
Jul 31 '06 #8
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?
--
Terry
"iwdu15" wrote:
it is executed, all variables have values, all variables have correct
values....every thing should work but it doesnt
--
-iwdu15
Jul 31 '06 #9
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
Aug 1 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

45
3601
by: Steven T. Hatton | last post by:
This is a purely *hypothetical* question. That means, it's /pretend/, CP. ;-) If you were forced at gunpoint to put all your code in classes, rather than in namespace scope (obviously classes themselves are an exception to this), and 'bootstrap' your program by instantiating a single application object in main(), would that place any limitations on what you could accomplish with your program? Are there any benefits to doing things that...
171
7723
by: tshad | last post by:
I am just trying to decide whether to split my code and uses code behind. I did it with one of my pages and found it was quite a bit of trouble. I know that most people (and books and articles) like it because you can split the code from the design. That is logical. But if you are the only one working on the code, it seem a little overkill. I use Dreamweaver to do my design and find it a bit of a hassle to have multiple files open...
88
8042
by: Peter Olcott | last post by:
Cab you write code directly in the Common Intermediate language? I need to optimize a critical real-time function.
8
2292
by: Wikicodia Admin | last post by:
Dears, Wikicodia is a wiki based project for sharing code snippets. We're collecting large number of code snippets for all code-based programming languages, scripts, shells and consoles. We wish you could help us. We're still BETA. Your suggestions, ideas and criticisms are very welcomed. We're waiting for you contributions. You can easily share and search our snippet using our Google Desktop Gadget. Share your C++ snippets to help the...
66
7452
by: Jon Skeet [C# MVP] | last post by:
I'm sure the net will be buzzing with this news fairly soon, but just in case anyone hasn't seen it yet: Microsoft are going to make the source code for the .NET framework (parts of it, including the BCL, ASP.NET and LINQ) available both for viewing and debugging into. I won't go into all the details here, as they're covered on Scott Guthrie's blog:
29
2959
by: Virtual_X | last post by:
As in IEEE754 double consist of sign bit 11 bits for exponent 52 bits for fraction i write this code to print double parts as it explained in ieee754 i want to know if the code contain any bug , i am still c++ beginner
15
2568
by: fyi | last post by:
My new blog on bits and pieces of PHP coding. http://bitspiecesphp.blogspot.com/ Have used all of them. Hope they're as useful to others: Use PHP to track email sender from your web site http://bitspiecesphp.blogspot.com/2008/06/use-php-to-track-email-sender-from-your.html Using PHP to solve the session_start() Error
4
1939
by: David | last post by:
Hi list. Do test-driven development or behaviour-driven development advocate how to do higher-level testing than unit testing? types of testing: unit integration system
6
1265
by: Christopher | last post by:
I've seen various ways of doing this, but what I want is to be able to take a base class pointer and know which derived class to cast to. For example I am going to make a base light class, that has a position and intensity. A derived classes class may be a point light which also has a falloff value. The derived class has all the base class methods and data in common, but has the additional falloff value get/set methods.
0
9157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9027
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7725
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2329
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.