473,378 Members | 1,607 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,378 software developers and data experts.

How to use a String Array for passing Values

Hi,

I have a simple query but im just not able to get it right.

Have a look at my sample code below
Expand|Select|Wrap|Line Numbers
  1. Sub Function1
  2.  
  3. My Code Here
  4. Function2(Year,Month)
  5.  
  6. End Sub
  7.  
  8. Sub Function2(Year,Month)
  9. Dim Str as String()
  10.  
  11. for 1 to 30
  12. Dim MyDate As New Date(Year, Month, i)
  13. Str = MyDate.DayOfWeek.ToString()
  14. Next
  15. Return Str
  16.  
  17. End Sub
  18.  
Function 2 Is used to get the Name of the Day.

Year and Month Parameter is Passed from Function 1 like this Function2(Year,Month)

My issue is

1)i want to add names of all the 30 days into one array

2)How can i return that array to Function1

3)Howe can i use that Array in Function 1 and assign each name to individual variable.

Please Suggest
Oct 21 '11 #1

✓ answered by !NoItAll

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim str() as String
  3. Dim MyDate as Date
  4. for 0 to 30
  5.     Redim Preserve str(i)
  6.     try
  7.         Str(i) = MyDate.DayOfWeek.ToString()
  8.     Catch
  9.         Exit For
  10.     End try
  11. Next
  12.  
  13. Return Str
  14.  
  15.  
Check the str.length to see how many days you have - not all months have the same number of days...

1 1759
!NoItAll
297 100+
Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim str() as String
  3. Dim MyDate as Date
  4. for 0 to 30
  5.     Redim Preserve str(i)
  6.     try
  7.         Str(i) = MyDate.DayOfWeek.ToString()
  8.     Catch
  9.         Exit For
  10.     End try
  11. Next
  12.  
  13. Return Str
  14.  
  15.  
Check the str.length to see how many days you have - not all months have the same number of days...
Oct 21 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Rob Mayo | last post by:
How can I create a pointer to a string array from VB.Net? I want to take a string array of variable size and pass it as a wParam on a message to a custom subclassed window. I've tried wrapping the...
3
by: Goh, Yong Kwang | last post by:
I'm trying to create a function that given a string, tokenize it and put into a dynamically-sized array of char* which is in turn also dynamically allocated based on the string token length. I...
2
by: Bnc119 | last post by:
Hello, I have written a C# COM server that has a few methods and a property called DataItems that returns an ArrayList. During the course of execution the ArrayList gets populated with several...
1
by: VCVCVC VC via DotNetMonster.com | last post by:
Hi , I want to pass a string array to an unmanaged COM Componet. The component should retrieve it. Pls help me to understand with a sample code. I have declared a BSTR* myStringarr, for this in...
2
by: rmathieu | last post by:
Hi, I want to initialize a static String array in MC++. What I want to do is to initialize my String array like the C# way: new String {"11", "22"} but I could not find an equivalent in MC++. The...
8
by: barbarowa | last post by:
I've coded a script to populate a drop down menu from a database but I can't seem to get the PHP script to pass the selected item. The database only has two fields, ID and ITEM. I want the user...
4
by: Colin Williams | last post by:
Hi I have a file list box with which i am passing the selected items to a string array (using copyTo), however i also need to pass the path of the FLB with each string in the array. Is it possible...
2
by: johnj | last post by:
I am converting an application I wrote in VB.NET to C#. I am not a C# guy, at all. I am having a problem passing values to a property in C#. I understand that it is probably not the best way of...
8
by: Pim75 | last post by:
Hello, I'm defining a string array like: Dim strArray() As String = {"1", "2"} Can I add some values to this string array later in the code? It's not clear to me how to do this. I hope...
3
by: vidhyapriya | last post by:
Hi all I am developing windows application using vb.net.I want to pass values to open form.I am opening only one form when user click the buttons several times.Useing delegate i am passing...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.