473,396 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

very strange behavor

If CStr(params(4).Value).Length = 0 Then params(4).Value = DBNull.Value

Debugging I check this:
? CStr(params(4).Value).Length = 0

False

? CStr(params(4).Value)

"3"

But executing the code params(4).Value = DBNull.Value is executed!!

p.s. Dim params(4) As SqlParameter, where sql parameter came from MS Data
access block


Nov 20 '05 #1
5 895
"Trapulo" <no**********@qui.it> schrieb
If CStr(params(4).Value).Length = 0 Then params(4).Value =
DBNull.Value

Debugging I check this:
? CStr(params(4).Value).Length = 0

False

? CStr(params(4).Value)

"3"

But executing the code params(4).Value = DBNull.Value is
executed!!

p.s. Dim params(4) As SqlParameter, where sql parameter came from MS
Data access block


Change the code from a single-line If-then to a block If-then:

If CStr(params(4).Value).Length = 0 Then
params(4).Value = DBNull.Value
end if

Check again to see if the code is /really/ executed. Sometimes the IDE
behaves as if the statement in a single-line if-then is executed, but it
isn't.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
Nov 20 '05 #2
Cor
Hi Armin,

That is a nice message.
I did not know that.

Thanks,

Cor
Nov 20 '05 #3
* "Trapulo" <no**********@qui.it> scripsit:
If CStr(params(4).Value).Length = 0 Then params(4).Value = DBNull.Value

Debugging I check this:
? CStr(params(4).Value).Length = 0

False

? CStr(params(4).Value)

"3"

But executing the code params(4).Value = DBNull.Value is executed!!


I don't think so. The 'If' is executed, not the 'Then' "branch",
nevertheless, the whole line is marked. You can see that by using the
block 'If...Then':

\\\
If ... Then
...
End If
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
Yes, if I split IF..THEN in more than one row the condition in evaluated.

Bug of the ide or of the compiler.. :(
"Armin Zingler" <az*******@freenet.de> wrote in message
news:eM**************@tk2msftngp13.phx.gbl...

Change the code from a single-line If-then to a block If-then:

If CStr(params(4).Value).Length = 0 Then
params(4).Value = DBNull.Value
end if

Check again to see if the code is /really/ executed. Sometimes the IDE
behaves as if the statement in a single-line if-then is executed, but it
isn't.

Nov 20 '05 #5
"Trapulo" <no**********@qui.it> schrieb
Yes, if I split IF..THEN in more than one row the condition in
evaluated.
This was not the quetstion. The condition is always evaluated.
Bug of the ide or of the compiler.. :(


IDE
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #6

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

Similar topics

4
by: Zhang Weiwu | last post by:
This is really very stange. I have a form like this: <form id="form_A"> xxxx </form> This form is on one page in a page of a web application, it is the only form on that page. on the end of...
6
by: leonecla | last post by:
Hi everybody, I'm facing a very very strange problem with a very very simple C program... My goal should be to write to a binary file some numbers (integers), each one represented as a sequence...
2
by: TB | last post by:
I am seeing a very strange problem as follows... I have a loop where a fair amount of processing is going on and near the top of the loop I access a class that has only static helper functions...
5
by: cody | last post by:
I have a very funny/strange effect here. if I let the delegate do "return prop.GetGetMethod().Invoke(info.AudioHeader, null);" then I get wrong results, that is, a wrong method is called and I...
2
by: Shapper | last post by:
Hello, I have this code: Dim cultureList(,) As String = {{"E", "en-GB"}, {"P", "pt-PT"}} Select Case Session("culture") Case "pt-PT" ... Dim cultureList(,) As String =...
12
by: John | last post by:
I can't get my head around this! I have the following code: <% .... Code for connection to the database ... .... Code for retrieving recordset ... If Not rs.EOF Then ... Do something...
2
by: peter | last post by:
Hi, I have very strange situation but first description ;) I have: 1) project in VB.NET, in this f.e. 1 function: Public Function Login(ByVal UserName As String, ByVal UserPassword As...
11
by: VijaKhara | last post by:
Hi all, I just write a very simple codes in C and vthere is a very strange bug which I cannot figure out why. The first loop is for v, and the second for k. There is no relationship between v...
4
by: Gotch | last post by:
Hi, I'm getting a very strange behaviour while running a project I've done.... Let's expose it: I've two projects. Both of them use a Form to do some Gui stuff. Other threads pack up messages...
112
by: Prisoner at War | last post by:
Friends, your opinions and advice, please: I have a very simple JavaScript image-swap which works on my end but when uploaded to my host at http://buildit.sitesell.com/sunnyside.html does not...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.