Pass Optional Values For Chars Arrays?

May 4, 2009

How can I pass optional values to chars arrays in a function?[code]...

View 1 Replies


ADVERTISEMENT

Optional Parameter Not Working When Trying To Pass Null Value To Database?

Apr 10, 2009

I am hardcoding an insert statement to a database, based on certain details a user enters into a windows form. The form has a few textbox and datetimepicker controls for the purpose. This form enters a single row in a single table in the database.The table has a few possible null columns defined, in those cases where the user does not have any data for those columns at that particular time.

I have to provide controls for passing data to those null columns nevertheless. In my case, I have two such columns that accept null values, and two corresponding controls - a textbox and a datetimepicker. The datetimepicker has a checkbox added to it so that if it is supposed to be null it doesn't pass the default current date value, and remains unchecked to explicitly specify that it is supposed to be null. By default it is unchecked.

My code is structured as follows:

Form1:
'the sub referenced here resides in a dll file in my dataaccesslayer code, and in my actual example is referenced properly.
'I have shortened the code here for simplicity

[code]....

Now it gives me an error whenever the code comes to the executenonquery(), and says something to the tune of "SqlDateTimeOverflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM."

I think the value of 'Nothing' from the subprocedure's paramter is not being assigned to the sqlcommand's parameter as a database NULL, which is what I need to pass to the database.I know instead of using optional parameters I can easily create overloaded subprocedures where one sub allows not passing values where the column(s) is supposed to null and other overloaded subs permit combinations of which column(s) are null or not. But it is simple as long as there is just one, or at the most two null columns in a table. If I have dozens of null values in a table that the user can choose to enter or not in a data entry form?

View 7 Replies

.net - Regex Replacing Non-words Chars In Strings, Ignoring Specific Chars?

Oct 8, 2011

In VB.net I've got the following line that removes all non-alphanumeric chars from a string:

return Regex.Replace(build, "[W]", "")

I now need to extend this to remove non-alphanumeric chars that aren't [] or _. I've changed the line to:

return Regex.Replace(build, "[W[]_]", "")

However I'm pretty sure that this says

replace non-word or [ or ] or _

how do I negate the tests for the [] and _ chars so that it says

replace non-word and not [ and not ] and not _

Some examples:

"[Foo Bar_123456]" => "[FooBar_123456]"
"[Foo Bar_123-456*]" => "[FooBar_123456]"

View 2 Replies

.net - Cast A List Object Of Chars In An Array Of Chars?

Nov 20, 2010

How to convert or make a cast of a List object typized as a container of chars like

Dim mylist As List(Of Char) = New List(Of Char)(New Char() {"1"c, "2"c})

in a simple array of chars as

Dim mychars() As Char

without make a loop for...

View 1 Replies

Pass An Optional Parameter To A Function Of Type System.Drawing.Color - Error "Constant Expression Is Required"

Mar 22, 2012

I want to pass an optional parameter to a function of type System.Drawing.Color. The problem I am having is that when I declare the function it says "Constant expression is required" but I have tried variations of the following, including integers, full qualified indentifiers, even old vbWhite constants to no avail.

[Code]...

View 14 Replies

Pass Arrays Hashes To VBA Via COM?

May 6, 2012

I am currently trying to pass an array of objects as a result to VBA but Excel is complaining the following:

'Function or interface marked as restricted, or the function uses an automation type not supported in Visual Basic.'

I have looked around on the internet and have seen similar issues but not to one I am trying to do.

My function is declared as follows:

<ComClass(Class1.ClassId, Class1.InterfaceId, Class1.EventsId)> _
Public Class Class1
#Region "COM GUIDs"
...

[Code]....

VBA is complaining about the System.Objects my question is how the heck are you supposed to pass and return arrays from .NET to VBA. Also the data that will be in the ArrayRes() is mixed type, its not just strings etc, its an array of arrays that can contain strings, integers doubles etc.

I chose VB .NET because I assumed it would be possible to map to VBA easier.

One last thing, if System.Object and Arrays in VB .NET is not the way, ie maybe theres another way via collections or lists, then Im open to that. I just need to get this data into VBA. Also I could move over to C# if needs be.

View 1 Replies

Pass Arrays To A Function?

May 18, 2009

I have an array of integers and I want to pass the array to a function that will add up the elements of the array and return the cumulative total of the elements of the array. So, if the array contains the values {1,2,3,4,5} the return value from the function would be 15.

View 2 Replies

Pass A Structure That Contains 2D Arrays As Byte To A C++ Dll

May 16, 2012

am trying to pass a structure that contains 2D arrays as Byte from VB.net to a C++ dll. The dll returns the structure with the 1D arrays filled. I am using UnmanagedType.ByValArray to pass the arrays from VB.net to C++.

Sample :

----------------------------------------- Structure -------------------------------------------------------
<Serializable(), StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)> _

[Code].....

View 2 Replies

Pass Arrays To A DLL From Visual Basic?

Aug 13, 2010

I need to pass an array by reference to a Fortran DLL. I'm trying to use the declaration

Public
Declare
Auto

[code]....

View 9 Replies

Pass An Array Of Arrays As A Function Argument?

Nov 11, 2010

I have several parameters consisting of separate System.Byte() arrays. What I need is the syntax for a function declaration where the parameter is an array of arrays - I do not want to delve into System.Collections, and it's my preference not to CType each array into an Object and then back into a Byte().

Problem I'm having here is that:

Public Function MyFunc(arrayparam() As System.Byte) As System.Byte()

accepts a single-dimensional Array of individual Bytes.

Then Public Function MyFunc(arrayparam() As System.Byte()) As System.Byte()

View 12 Replies

Adding Values Of Two Arrays?

Apr 26, 2012

I'm making an application in school where I have to display the values of domestic, international, and total sales of company "Conway Enterprises." Everything seems to be working except it is not displaying the totalCompany sales as a currency. I'm sure it's probably an easy fix but I've been searching the internet and re-reading my book for awhile with no results. Below is the code, as I said everything seems to be working fine aside from adding the two array values and then displaying them as currency.

Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub

[code]....

View 1 Replies

Do Arrays Take Up Space Even Without Values In Them In .net

Sep 28, 2011

I have a program in VB.net that uses a 3D array:

Private gridList(10, 900, 900) As GridElement

Now, I just used a Memory Profiler on it (because my application is having some major leak issues or something) and apparently, this array (containing at the moment of testing 0-30 elements at one time) is using 94% of the memory currently in use by my application. Even when it is empty it takes up huge amounts of memory.

My only assumption is that even empty arrays take up space! This puts a major blow into my plans!

My Question:

Is there any alternative to this that allows me to still have the same abilities to map i.g. I've been using it like this:

Dim cGE as GridElement = gridList(3, 5, 7)

but doesn't hog up so much memory for things that aren't using memory?

View 1 Replies

Initializing The Arrays With Values?

Sep 27, 2011

I'm using a structure to hold three arrays:

structure myStruct
dim arrayOne() as char
dim arrayTwo() as char
dim arrayThree() as char
end structure

But how do I go about setting them a value, I've got my instance of myStruct

dim aStruct as new myStruct()

If I try redim, it just tells me it can't change the dimensions of an array, so how do I got about initializing the arrays with values?

View 5 Replies

Mapping Values Of Two Arrays?

Oct 22, 2009

I have two arrays with equals number of values, is there a way to match the values exactly in same order, as such:

FirstArray("1,"2","3","4")
SecondArray("John","Samantha","Tony","Joe")
1---John

[Code].....

View 1 Replies

Mulitply Values In Two Arrays?

Sep 25, 2010

I am working on a program where I need to multiply the value (int) times the value (dec) of another array to calculate the total cost of books in inventory. [code]....

View 2 Replies

Searching Arrays For Values?

Mar 4, 2010

i am working on a VB project for Chem and im making it for converting grams to moles, moles to molecules or any thing like that. and i have about 110 elements set up and working fine the way that im doing it but i have a feeling this is a horrible way and to abundant.

i have a textbox set up to if i type in the element He and hit enter it will find ChemElement(1)="He" and it calls "Sub DisplayElement(ByVal number As Decimal, ByRef label2 As Label)"

Which then displays the Chemical mass into a Label.

[Code]...

View 17 Replies

Assigning Arrays Values From File

Jun 3, 2011

im a newbie here, im taking intro to programming wth VB in college and im having problem with the homework here's what im supposed to do

[Code]...

View 7 Replies

Changing Arrays Location Values?

Apr 23, 2009

All variables and Arrays have been declared properly the problem Is when the user enters a new number using a scroll bar

LottoNumber = HScrollBar1.Value
Label2.Text = "Number Selected: " & LottoNumber

The out put of the variable count stays at 1 so the output stays at (Pick # 1 of 6) and doesnt increment at all and does not build the OutPut string

'IF The LottoNumber Location Value is 0 in the Array selectedLotto THEN mark it by making the Loacation Value to 1
If selectedLotto(LottoNumber) = 0 Then

[Code]....

View 3 Replies

Declare Defaults Values For Arrays?

Feb 18, 2010

Why can't I declare values for an array inside a module?

View 2 Replies

Storing Values In Arrays Fom Inputbox?

Feb 5, 2009

i have declared an array which i want to populate with names, as they are entered into an input box.It does not seem to work i have tried many other methods with the array but to no success.

Dim namearray() As String
Dim i As Integer
name = InputBox("Enter the candidates name:", "candidatename", "", 500, 500)
name = namearray(i)
i = i + 1

View 6 Replies

User Added Values To Arrays?

Jun 19, 2012

I've searched until my eyes and fingers feel as if they are going to bleed. I cannot come up with the answers I'm looking for. I want to essentially create an inventory system without using a database (part of why the eyes are bleeding, keep getting directed on side tangents), that is fed by the user. IE, User enters a name of a product, it is added in to an array. As a designer I will not know the exact number of elements to be held within the array. The user will enter their chosen item in to a text box. So I'm looking for a way to take the value in the text box and add it to the array. I believe I would use the reDIM function to do this, but beyond that I've got nothing. I'm unsure of how to reference the value stored in a text box.

View 7 Replies

VS 2008 Byte Arrays - Getting More Values

Jun 11, 2010

I am having some major problems with byte arrays. First off the bigger array I have the more values go missing, I originally wanted to make a huge array and just dump like a 100mb chunk of memory in it but when I did that every byte in the array returned 0. So I experimented a bit and found 4kb to be the biggest chunk size to reliably not return 0.. ok I figured I'll just loop the 4kb and glue them back together later but no such luck, after being combined into the main array the bigger the number gets the more values that should be there just aren't.

Here's a code sample:
Dim retval(4095) As Byte
Dim combval(RLen) As Byte
For i = 0 To RLen - 4095 Step 4096
ReadProcessMemory(ProcAccess, i, retval, 4096, 0)
retval.CopyTo(combval, i)
Next i
WriteLine(combval(321603964))
WriteLine(ReadMemory(321603964, 1)(0))

So with the last 2 lines if I pull up some smaller number like 8 digits or so it reports back no problem but anything slightly bigger like the number i have written in there right now is just 0. After some additional research I discovered that the reason why 4kb is the max size I can reliably get is coz that's the size memory chunks are made of, "page" as they call it. Why the memory reading drops off at higher addresses alltho I suspect it has something to do with the way memory is structured and I am just not hitting the startpoint of a page anymore due to an offset or something somewhere.

View 3 Replies

.net - Find Common Values In Several Arrays Or Lists

Dec 23, 2011

Find common values in multiple arrays with PHP Pretty much does what I need, but in PHP, I need VB. My situation is I am trying to create an intelligent stock pick system based on multiple stock locations. At the point of invoicing, we loop through the items invoiced and check the stock database for available stock.

If all items on the invoice are available to pick from stock location 1, then all should be picked from stock location 1... etc. If all most items are available from stock location 1 except one or two, then pick all stock from stock location 1 except for the exceptions which should be picked from the location with the highest available stock. Finding highest available stock is simple, but I can't work out how to analyse the stock availability from multiple locations and finding the common stock locations.

[Code]...

View 2 Replies

Compare Arrays And Listboxes Values In VB 2010

Jul 22, 2011

I have a program that has to store a pre-made array that contains strings (moviename, moviegenre).

I setup all the items in the array already, example:

moviearray(0,0) = "Green Lantern"
moviearray(0,1) = "Action"

For this example, if the user selected "Green Lantern" from my listbox, then the label needs to display "Action". So yeah, it's a 2-column array: first column = movie name, 2nd column = movie genre. Now, I have a listbox containing all of the movie names (not entered by the array, but entered through the Item property of the listbox). When a selection is made in the listbox and a button is clicked, I need to have the genre of the movie output to a label. That is where I am stuck, I just can't figure out to compare what's in the list box with the first column of the array to output the 2nd column to the label.

View 15 Replies

Find A Matching Pair Of Values In Two Different Arrays?

Apr 11, 2010

How to find a matching pair of values in two different arrays? Here's the scenario:

Index Array1 Array2
0 1 3
1 2 5

[code].....

View 2 Replies

Initialize Arrays - Get Values For Array Elements

Nov 5, 2009

How to get values for array elements in VB.nET from the user.also i wanted to display these values in the combo box.[this is easy i could manage this].

View 2 Replies

Set X,y,z Values From Text File Into Separate Arrays

Nov 7, 2011

I have been trying to find out how to do this for days now, so I am finally asking how. I am newish to programming. Here is my problem.

I am trying to extract x,y,z coordinates from a text file arranged as such:

x,y,z
x,y,z
x,y,z
etc.

I need to be able to extract the x column into an array, the y into an array, and the z into an array. I learned how to pull it into a string, and how to split for every line, but i don't know how to split after each comma and separate them.

View 1 Replies

Class Property Arrays Not Holding/ Updating Values

Oct 1, 2011

I am trying to use several Class arrays to hold values that I will cycle through at a later point to perform some calculations. I need to change the array sizes to fit the data as it is entered. I am using one procedure to set the first element of each array and then a separate procedure to pass the additional values as they are entered.

Until my last attempt at changing my code, my StartBalance sub seemed to work, I could step through and see the values assigned to the class arrays in the code block. However, when it moved on to the Transaction sub, it did not recognize that the first set of values were set, the array shows zero values for index 1.

I have gone through several changes trying different ideas from reading blogs and articles, but I guess I am not understanding how these work. I even used the class arrays directly instead of the Property procedures to see if I would get a different result, but I do not.

I believe I must be approaching this incorrectly and though I can find dozens of examples of setting class variables and even a couple on using arrays as class variable, I can not find any that show how to then pass values to those arrays.

Public Class Statement
Private _tranDate(1) As Date
Private _amount(1) As Double

[Code]....

View 8 Replies

Pass Key Values To Other App?

Jun 22, 2010

I want to make a program that control powerpoint slides

for example, when I start power point in presentation mode

as I click the button, then slide goes to next. And when I click one more, then go next slide.

I don't know how to send message to powerpoint in VB.

View 2 Replies

Pass Values From One App To Another

Feb 4, 2009

I am in the process of creating a program that needs to pass some information to another program. The program that needs to receive the data is meant as an update program to the first. I send a new copy of the host program over the sockets connection, then I need to pass the file name and location to the update program. After this information is sent the host program will quit so that the update can overwrite the host with the new version. The the update program restarts the host and everything goes on like normal. I have everything all-ready in place, except for passing the file information. I could just save the information in a text file and read form this, but it seems messy and illogical.

View 6 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved