Passing Null Decimal Value To Function?
Jul 20, 2010
I have a Function within a data access layer, which accept a number of parameters. Among these is a decimal value, but in some cases the decimal value with be NULL, here is the code from the function
I am using the following code in my code file to pass the value to the function...
Convert.ToDecimal(textbox1)
How can I pass a NULL value to my function?
View 6 Replies
ADVERTISEMENT
Mar 30, 2010
I tried this
Dim value As
String
Dim returnValue As
[code]....
View 8 Replies
Feb 8, 2011
I have a function that takes in a number of parameters.. it then does a db insert.i have a foreign key on one of the fields (modelID)i want to pass a NULL if no model ID is selected.[code]but now i get an error saying: Nullable object must have a value.if i pass in a 0, it does not insert because it breaks the DB constraints.
View 4 Replies
Sep 22, 2010
I think this is a pretty basic question, but I just want to clarify. If I have a variable with a null value, and pass it as a parameter that is optional, will the parameter get the null value, or the default value?
dim str As String = "foo"
dim obj As Object
//call 1
[code].....
View 1 Replies
Jun 6, 2011
I have a function that accepts a String by reference:Function Foo(ByRef input As String)
If I call it like this:
Foo(Nothing)
I want it to do something different than if I call it like this:Dim myString As String = Nothing Foo(myString) Is it possible to detect this difference in the way the method is called in VB .NET?All the logic is in the second overload, but I want to perform a different branch of logic if Nothing was passed into the function than if a variable containing Nothing was passed in.
View 3 Replies
Apr 9, 2012
i have a stored procedure to insert data into table create procedure insertdata
[Code]...
View 11 Replies
Mar 25, 2009
i'm not 100% sure about sql server but i think it doesn't accept null value for date type columns but in oracle, a date column can accept a null value. and since i'm using oracle, this is causing some problems because in my form, a textbox item bound to a date column will not accept a null value. reading thru some threads, it would seem that it is not possible to pass a null value to a date type in .Net.
[Code]...
View 2 Replies
Jan 27, 2011
I have a class and method exposed to a client asp.net app. The class looks like
<DataContract()> _
Public Class Class1
Private v_string As String
Private v_integer As Integer
[code]....
The method is declared as
<OperationContract()> _
Function GetStuff(ByVal bar As Class1) As String
In the client code I create an instance of Class1 and set the values for v_string and v_integer, but using Wireshark to look at the xml being sent to the server only a value for v_string is being sent as part of Class1. I'm guessing this is because it considers the value of v_integer to be null/not set. Here is an example of the client code.
Dim MyService as New Service1.ServiceClient
Dim test as New Service1.Class1
test.P_integer = 1
[code]....
how different types are passed/used since Integer is a intergral type and String is a class, but can't seem to work out what to do to fix the problem.
View 4 Replies
Jun 27, 2012
What is the cleanest, most readable way to String.Format a decimal with the following criteria
start with a sign symbol (+ or -)
a fixed number of fraction digits
no decimal separator
right aligned
pre-padded with "0"'s
View 3 Replies
Mar 22, 2011
I have a question concerning some homework. Here is my answer:
Dim intResult As Integer
intResult= Square(4)
lblResult.Text = CStr(intResult)
Now, if I understand functions correctly, this statement should pass the value 4 to:
Function Square( ByVal intValue As Integer ) As Integer
Return intValue^2
End Function
...and assign it's return value to "intResult".
View 6 Replies
Sep 15, 2010
I have a Job Register Table and that table doesn't have any records.
This is my LINQ code:
Dim QRecordCount = (From LC In CntxtJobDetails.JobRegistrations _
Where LC.JobCode <> 0 _
[code].....
View 1 Replies
Dec 5, 2011
I'm using VB Express 2010.
I have coded a function (let's call it my_boolean_function) on a form. The last line in the function returns the value, i.e.,
Return my_boolean_function.
The function performs correctly, but I get the warning:
Variable 'my_boolean_function' is used before it has been assigned a value. A null reference exception could result at runtime.
A solution to this has been discussed recently on this forum. One contributor suggested something that would mean initializing my_boolean_function to null
However, wanting to dig a bit deeper, I'm asking why does a function return value have to be initialized (to null)? Variables don't have to be yet the warning calls my_boolean_function a variable.
View 3 Replies
Jun 21, 2009
display a Decimal (or double) to elapsed time [h]:mm:ss (hours:minutes:seconds)using vb.net?
example:
if you were to type "1.34666666666667" into a cell in Excel then choose Custom Format [h]:mm:ss The result is an elapsed time of "32:19:12". Using the OADate function only runs on a 24 hour clock so this does not work for longer durations unfortunately...
View 4 Replies
Feb 21, 2010
Private Function Token() As String
Dim Length As Byte
Length = 10
Dim Chars As Char() = New Char() {"a"c, "b"c, "c"c, "d"c, "e"c, "f"c, _
[code]....
is the above bolded line a correct .. it s not working too and the above code is used to generate a random password for users which should be displayed on the text box?
View 3 Replies
Aug 3, 2011
I am having a problem figuring this out. The text that is bold is where the problem is.
Imports Microsoft.Win32
Console.WriteLine(WMILookup("Win32_Bios","SerialNu mber"))
Private Function WMILookup(ByVal WMIClass as String,ByVal WMIItem as String) As String
[Code].....
View 2 Replies
Sep 8, 2010
I have a .aspx webform, with code behind to handle data entered by user, most fields are in double.At business layer, at other class, let say there is a function: [code]I just wondering whether this is the correct way of writing it? And if I have more than 20 fields of double value, then I should declare additional 20 double value?
View 2 Replies
May 27, 2010
I have a function that search database based on the 2 textbox value. I have a difficulty to call the function and pass the text box value to the function. This is my function: So I get this error:
{"Object reference not set to an instance of an object."}
Function getname(ByVal SearchedName As String, ByVal SearchedFirstName As String) As String
Dim temp As New System.Data.SqlClient.SqlCommand
Dim temp2 = ""
Dim sSQL = " select SearchedName, SearchedFirstName from student where SearchedName =@SearchedName AND SearchedFirstName = @SearchedFirstName"
[Code] .....
View 6 Replies
Jan 31, 2012
I have function in my asp.net/vb application with following signature:Public Function ExtractText(node As XmlNode) As String..I want to call it/pass xmlnode. How to create an Xml node with value:<mynode Id="7743" Type="context" StartNode="4356" EndNode="1234"></mynode>
View 1 Replies
Apr 3, 2009
is it possible for a VB.net function with a return type of integer to return null ?
View 3 Replies
Apr 29, 2009
I need a function which will Round a number UP to the specified decimal precision, exactly the same as how Excel's RoundUp function works:
Roundup(dblVal, intDecPlaces)
So I need the following:
Roundup(0.896523, 4)
would return
0.8966
However, everything i've tried/found simply rounds to the nearest whole integer, or returns a normal rounded value, hence the above would return
0.8965
I've tried the following:
Math.Round(dblval, intPrecision, midpointrounding.awayfromzero)
' and
Math.Round(dblval, intPrecision, midpointrounding.toeven)
And even custom functions, such as:
Public Function RoundUp(ByVal varValue As Object, _
ByVal iNum As Integer) As Double
'ignore the data types here, I was playing to see 'if changing any of the data types would swing 'the results (knowing full well they wouldnt make 'a difference, thats how fed up with this I am!)
Dim lNum As Long, xVal As Double, xVar As Object
xVar = Fix(varValue)
[CODE]...
I've even looked at converting this to a string, looking at the Xth decimal place, and incrementing it up by 1, then converting it back to a double, while this works (sort of) it seems to be a very roughshod way of doing it, and I'd rather do it mathematically than with lots of data conversion.
View 6 Replies
Jun 23, 2011
I am trying to call the method with the following declaration[code]...
The structs should both be twodimensional arrays with indexes of 4,4 and 5,4 respectively. The second one is an out parameter.
View 1 Replies
Dec 29, 2008
I wrote vba function in excel and I want to call this function in vb.net with parameter passing.
View 2 Replies
Jul 19, 2011
Let's says I have a class called Customer :-
Code:
Dim Cust as New Customer("Fred")
I also have a function in a seperate class :-
Code:
Shared Function Example(Example As Customer)
How do I refer to the class itself from within itself? For example :-
Code:
' from within the Customer class, call the Example function
AnotherClass.Example(Me??)
View 11 Replies
Jul 23, 2009
pass an array to a function, like the code below shows
Private Sub SomeFunction(ByVal PassedArray() As String)
For i As Integer = 0 To PassedArray.Count - 1
Debug.WriteLine(PassedArray(i))
[code]....
But is there a way to pass a constant array to a function in VB .Net, for instance in PHP you could write
function SomeFunction($array)
{
for($i=0;$i<count($array);$i++)
{
[code]....
So to reiterate: Is there any way to pass a constant array directly to a function in VB .Net? Is there any benefit in doing so? I imagine a few bytes of memory could be spared.
PS.SomeFunction({"some", "array", "member"}) ' this obviously gives a syntax error
View 3 Replies
Dec 2, 2011
It looks like passing a list's enumerator to a function "byval" is quite different than passing it "byref". Essentially, regular "byval" passing will NOT change the caller's "enumerator.Current value", even if the function advances the enumerator. I was wondering if anyone knows why this is the case? Is an enumerator a primitive like an integer, without an object reference, and hence changes to it don't get reflected in the caller?This function is byval, and gets stuck in an infinite loop, spitting out "1" message boxes, because the enumerator's "current" never advances past 5.[code]The difference between the two functions is only whether the listFirstItem__ function accepts a byval or a byref enumerator.
View 2 Replies
Apr 30, 2009
I am trying to use a simple quicksort routine for a multidimensional array but cannot figure out the syntax. I am stumped because it works fine in VB6 but no luck in .Net
Array Declaration:
Dim sArrIn(25000, 3) As String 'sort key (pkg, kitting, zip), kitting, data
Function Call:
[Code]....
View 4 Replies
Jan 6, 2011
I am missing something obvious here
I have an array that is declared as
Dim
array1(,)
As
[Code]....
View 4 Replies
Feb 18, 2010
MotherTongueTxtBox.Attributes.Add("onblur","val_Length(MotherTongueTxtBox.text,"hi friends",Length);")
in the above statement val_length s a javascript function in tat function the first parameter shd b the contents of the text box ,the second parameter s a string type, is the statement correct i think it s wrong can u suggest a correct valid statement
View 1 Replies
Nov 16, 2011
Trying to generate a Datagridview based on a query which is working fine.
Basic method is:
Create DbAdapter (MySQL) Create DataSet Fill Dataset with DbAdapter.Fill Set Datasource of DG to Dataset
Works fine, have used a commandbuilder to handle updating, inserting and deleting. Where this doesn't work is if I pass a MySQL function in my query, e.g.
SELECT FROM testtable TestID, SomeFunctionForward(someproperty), anothersfield
A quick check shows the field omitted from Update and Insert. How do I go about 'setting this property' so it will work on the query with the CommandBuilder. It needs to be done in inverse, i.e.
INSERT INTO testtable TestID, someproperty, anothersfield VALUES SomeFunctionBackward("somepropertyvalue"), "anothersfieldvalue"
View 16 Replies
Jul 4, 2009
i have a very simple problem but i can't figure how to fix it.I'll explain, i have 3 array named "Auto, Legumes, Films". I i making a function so whenever the selecteditem of the combobox change(Auto, Legumes or Films) the name of the selecteditem is passed to a function. The function use this name to display the items of the corresponding table in a listbox.The 3 different item name in the combobox match the name of the 3 tables, so i want to be able to re-use the name dynamically in my function.
Code where i call the function:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbchoix.SelectedIndexChanged
[code].....
View 1 Replies