G
Guest
Hi. I have a Public Function which requires 2 parameters as follows...
Public Function Test(ByVal 1 as String, ByVal 2 as String)
Prior to calling this function, I fill a dataset(ds) with an undetermined
amount of records, and then use a datatable(dt) to reference the rows of the
datatset.
Dim ds as New DataSet
'Fill DataSet
dt = ds.Tables("Table")
Test(dt.Rows(i)(0), dt.Rows(i + 1)(0))
As you can see the first and second rows from the dataset are passed to the
function. I am having a problem whenever only 1 record exists in the
dataset. When only 1 record exists I get the error message "There is no row
at position 2". Is it possible to send an empty string("") to the function in
order for the function to still run? Or, is there a better way to prevent
this error? Thanks.
Public Function Test(ByVal 1 as String, ByVal 2 as String)
Prior to calling this function, I fill a dataset(ds) with an undetermined
amount of records, and then use a datatable(dt) to reference the rows of the
datatset.
Dim ds as New DataSet
'Fill DataSet
dt = ds.Tables("Table")
Test(dt.Rows(i)(0), dt.Rows(i + 1)(0))
As you can see the first and second rows from the dataset are passed to the
function. I am having a problem whenever only 1 record exists in the
dataset. When only 1 record exists I get the error message "There is no row
at position 2". Is it possible to send an empty string("") to the function in
order for the function to still run? Or, is there a better way to prevent
this error? Thanks.