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

how to read data in calendar form

6
Hi all. I'm new here and also new in VB programming. Just need a little help from you all. My question is how VB can read data in calendar form. The coding that I create is like this.

Expand|Select|Wrap|Line Numbers
  1. For Day = 1 To 31
  2.   Line Input #2, strLineDataED
  3.   'intMonth = 0
  4.   'Np = 1
  5.   'For Month = 1 To 12
  6.     'strMonthP(intMonth) = Format(Mid(strLineDataED, 1, 7), "00.00")
  7.     If Month = 1 Then
  8.       ED(Day, Month) = Format(Mid(strLineDataED, 1, 7), "00.00")
  9.     Else
  10.       'ED(Day, Month) = Format(Mid(strLineDataED, Np, 7), "00.00")
  11.       'Np = Np + 7
  12.     'End If
  13.   'Next Month
  14. 'Next Day
But the problem is the data space in every field must have 7 spaces before it can read data in other fields. Can anyone let me know how to alter the coding so that the space can be in free format? Because it really takes time to arrange all data to have 7 spaces as for the data is very much. tq.
Aug 28 '07 #1
11 1323
Killer42
8,435 Expert 8TB
Hi zaaba, welcome to TheScripts (and VB).

Can you please explain your situation in a little more details? For instance, what version of VB are you using? Also, it's not entirely clear whether you have existing data and need to write code to read it, or you are trying to decide how to format the code, and how to read it, or what.

If you already have the data and you just want you program to read it, then I'm sure we can help you set up your code to read whatever is there. It should not be necessary to change the format of the data to suit your code.
Aug 28 '07 #2
zaaba
6
Can you please explain your situation in a little more details? For instance, what version of VB are you using? Also, it's not entirely clear whether you have existing data and need to write code to read it, or you are trying to decide how to format the code, and how to read it, or what.

If you already have the data and you just want you program to read it, then I'm sure we can help you set up your code to read whatever is there. It should not be necessary to change the format of the data to suit your code.

--------------------------------------------------------------------------------
ii killer42...

thanks for your attention..
sori if u r not clear wit my ques..
i'm using vb 6.0...actually i already have existing data n need vb to read it from a file...but da prob to me is the data are in calendar form which is have days in column n month in fields...Each of the data have their calculation to be done by vb 6.0..Based on the code, the format of fields of existing data must have 7 space but i want to change it to free format...is my xplanation clear for u?..thanks alot ya..
Aug 29 '07 #3
Killer42
8,435 Expert 8TB
Can you show us a sample of the data you want to read in?
Aug 29 '07 #4
zaaba
6
dis is part of the data and the data is not in format 7 space each...from left to right is the data for month which are have 12 data meanwhile from top to bottom is the data for days which actually have 31 days.

53.30 10.10 0.00 12.60 2.50 7.60 2.50 1.20 30.40 27.90 1.70 71.10
40.60 12.60 0.00 5.00 0.00 0.00 5.00 2.50 2.50 11.40 2.50 0.00
13.90 0.00 0.00 10.10 0.00 0.00 35.50 2.50 1.20 2.50 1.20 6.30
58.40 0.00 0.00 2.50 0.00 0.00 5.00 0.00 2.50 0.00 0.00 2.50
66.00 0.00 0.00 1.20 0.00 0.00 0.00 0.00 27.90 7.60 30.40 0.00
12.60 0.00 2.50 0.00 1.20 72.30 0.00 0.00 12.60 0.00 0.10 0.00
30.40 2.50 1.20 0.00 2.50 2.50 0.00 2.50 0.00 5.00 12.60 0.00
19.00 15.20 0.00 0.00 0.00 0.00 2.50 3.80 21.50 0.00 2.50 0.00


thanks
Aug 29 '07 #5
pureenhanoi
175 100+
dis is part of the data ... 2.50 0.00
Killer42, do you know his meaning ?
Aug 29 '07 #6
Killer42
8,435 Expert 8TB
Killer42, do you know his meaning ?
I'm not sure.

zaaba, do you mean that you have a column for each month, and a row for each day, like in a spreadsheet?

In any case, if you use something like Line Input # to read each line into a string, you should then be able to use the Split() function to chop it into 12 entries, breaking at the spaces. I'm not sure how Split() will handle multiple spaces in a row, though.
Aug 29 '07 #7
zaaba
6
Killer42, yes the data is like in a spreadsheet..how can vb know for example 53.30 is the data for day =1 and month =1 meanwhile 10.10 is the data for day =1 and month =2 and so on..by the way, can u explain about the Split function and how to create the split coding if u dont mind...thanks
Aug 29 '07 #8
zaaba
6
dis is part of the data ... 2.50 0.00

Pureenhanoi..
the data means for example 2.50 is the data for day=1 and month =1 meawhile 0.00 is the data for day=1 and month=2...actually from left to right is data for months which is each of them present the data for month 1,2...until 12..meanwhile from top to bottom is data present days which are actually have 31 days each month.. for the months that are not 31 days, i put the value as 0.00..is it clear?..
Aug 29 '07 #9
pureenhanoi
175 100+
dis is part of the data ... 2.50 0.00

Pureenhanoi..
the data means for example 2.50 is the data for day=1 and month =1 meawhile 0.00 is the data for day=1 and month=2...actually from left to right is data for months which is each of them present the data for month 1,2...until 12..meanwhile from top to bottom is data present days which are actually have 31 days each month.. for the months that are not 31 days, i put the value as 0.00..is it clear?..
Like Killer42 said, you can use split() function instead of Mid$() to get sub-string.
Let see: if we have a string with 12 groups of number (seperate by Space)
now, get each seperated group like this
Expand|Select|Wrap|Line Numbers
  1. Dim strLine As String
  2. Dim temp As Variant
  3. Dim ss As Variant
  4. Dim Month As Integer
  5.  
  6. 'Read each line from file into strLine here
  7. temp  = Split(strLine," ")    'split each group by Space
  8. Month = 1
  9. For Each ss In temp
  10.   Debug.Print "Month = " & month & " >> Data = " ss & vbCrLf
  11.   Month = Month + 1
  12. Next
  13.  
Aug 30 '07 #10
pureenhanoi
175 100+
Hi all. I'm new here and also new in VB programming. Just need a little help from you all. My question is how VB can read data in calendar form ...
Your code should be:
Expand|Select|Wrap|Line Numbers
  1. Dim strLineData As String
  2. Dim temp As Variant
  3. Dim ss As Variant
  4. Dim nMonth As Integer
  5. Dim nDay As Integer
  6.  
  7. nDay = 1
  8. While Not EOF(#2)   'this traps error if the file has fewer than 31 Lines
  9.   Line Input #2, strLineData         'read entire row into varriable
  10.   temp = Split(strLineData," ")   'Split each line into an array
  11.   nMonth = 1
  12.   For Each ss In temp    'traps error if line has fewer than 12 groups of number
  13.      Debug.Print "Day " & nDay & ",Month " & nMonth & " >> Data=" & ss
  14.      nMonth = nMonth + 1
  15.   Next
  16.   nDay = nDay + 1
  17. Wend
  18.  
Aug 30 '07 #11
zaaba
6
pureenhanoi.....

i'll alter my coding as u create...thanks a lot ya for your help...really appreciate it :)
Aug 30 '07 #12

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

Similar topics

7
by: bass-man | last post by:
I am trying to include a dynamically changeable file in my website with PHP and Javascript so I am using a hidden field to hold the name of the file I want to include, and I am using the$_GET...
10
by: vinu | last post by:
I have a javascript file named select.js. This is a file which is use to pop up a calendar, when clicked on a calendar icon in an ASP file. have a close button in the calendar. When i click on the...
6
by: stephan.vanbeerschoten | last post by:
Hi All, I am relatively new to MS Access but am wel suited in general relational databases. I seem to be unable to accomplish the displaying of query results that return more then one line item....
2
by: Chuck Hartman | last post by:
I've been trying to add an ImageButton object to a Calendar table cell, but so far I am unable to handle the Command event from that button in my form's code behind. Below is an example of what I...
0
by: keekaye | last post by:
This was working ok but I changed something and I don't know where but it's no longer working. I get "Could Not Start Session" error. I'm sure it's something obvious but this is my first stab at...
3
by: thorpk | last post by:
I posted this problem earlier in the month and some one decided it was better to change the subject and ask a completely different question. I am therefore reposting. I am hoping some one can...
10
by: sufian | last post by:
I am new to the world of PHP. Below is my simple PHP file "invite.php" with a form having an image send button (I have to use the image send button because it is the requirement, may be this is...
4
by: gubbachchi | last post by:
Hi all, Please anybody help me solve this problem. I am stuck up with this from past 2 weeks. I am developing an application where, when the user selects date from javascript datepicker and enters...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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: 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...

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.