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. - For Day = 1 To 31
-
Line Input #2, strLineDataED
-
'intMonth = 0
-
'Np = 1
-
'For Month = 1 To 12
-
'strMonthP(intMonth) = Format(Mid(strLineDataED, 1, 7), "00.00")
-
If Month = 1 Then
-
ED(Day, Month) = Format(Mid(strLineDataED, 1, 7), "00.00")
-
Else
-
'ED(Day, Month) = Format(Mid(strLineDataED, Np, 7), "00.00")
-
'Np = Np + 7
-
'End If
-
'Next Month
-
'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.
11 1323
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.
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..
Can you show us a sample of the data you want to read in?
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
dis is part of the data ... 2.50 0.00
Killer42, do you know his meaning ?
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.
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
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?..
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 -
Dim strLine As String
-
Dim temp As Variant
-
Dim ss As Variant
-
Dim Month As Integer
-
-
'Read each line from file into strLine here
-
temp = Split(strLine," ") 'split each group by Space
-
Month = 1
-
For Each ss In temp
-
Debug.Print "Month = " & month & " >> Data = " ss & vbCrLf
-
Month = Month + 1
-
Next
-
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: -
Dim strLineData As String
-
Dim temp As Variant
-
Dim ss As Variant
-
Dim nMonth As Integer
-
Dim nDay As Integer
-
-
nDay = 1
-
While Not EOF(#2) 'this traps error if the file has fewer than 31 Lines
-
Line Input #2, strLineData 'read entire row into varriable
-
temp = Split(strLineData," ") 'Split each line into an array
-
nMonth = 1
-
For Each ss In temp 'traps error if line has fewer than 12 groups of number
-
Debug.Print "Day " & nDay & ",Month " & nMonth & " >> Data=" & ss
-
nMonth = nMonth + 1
-
Next
-
nDay = nDay + 1
-
Wend
-
pureenhanoi.....
i'll alter my coding as u create...thanks a lot ya for your help...really appreciate it :)
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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....
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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...
|
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: 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...
|
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,...
|
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...
| |