text:
- Sanchit Karve
printf("I'm a %XR",195936478);
CONTACT ME : born2c0de AT dreamincode DOT net
- *New* UPDATES
The reader is expected to have a basic working knowledge of Visual Basic Data
Types, Arrays, Loops and Library Functions.
You might have heard several terms in File Handling such as Fields, Records etc.
but may not know what they mean.
To understand it simply remember this set of relationships:
8 Bits = 1 Byte/Character
Many Bytes/Characters = 1 Field (or String)
Many Fields = 1 Record
Many Records = 1 File
Many Files = 1 Database
As far as Visual Basic 6 is concerned, there are three modes in which a file can
be accessed.
- 1) Text Mode (Sequential Mode)
- 2) Random Access Mode
- 3) Binary Mode
Hence, any number written in this mode will result in the ASCII Value of the
number being stored.
For Example, The Number 17 is stored as two separate characters "1" and "7".
Which means that 17 is stored as [ 49 55 ] and not as [ 17 ].
In the Binary Mode, everything is written and retrieved as a Number.
Hence, The Number 17 Will be stored as [ 17 ] in this mode and
characters will be represented by their ASCII Value as always.
One major difference between Text Files and Binary Files is that Text Files
support Sequential Reading and Writing. This means that we cannot read or write
from a particular point in a file. The only way of doing this is to read through
all the other entries until you reach the point where you want to 'actually'
start reading.
Binary Mode allows us to write and read anywhere in the file. For example we can
read data directly from the 56th Byte of the file, instead of reading all the
bytes one by one till we reach 56.
Just like the Binary Mode, the Random Access Mode allows us to gain
instant access to any piece of information lying anywhere in the file at a cost.
In this case, we must standardize each piece of information.
For example, if we need to store a few names in the file Random Access Mode
requires us to mention the length of the 'Names' Field.
Some Names might not fit and for the shorter names the space is inefficiently
used. Random Access Mode allows us to read or write data at a particular
record position rather than a byte position like in Binary Mode.
A Good Example of Sequential Mode is the Audio Cassette. If we have to
listen to a particular Song in the cassette, we have to play the tape right from
the beginning until we reach the beginning of the song.
And so obviously, CDs, DVDs etc. are examples of Binary Mode ( and even Random
Access Mode )
Part-I deals with Sequential Files, Part-II with Binary Files and Part-III with Random Access Files.
You should read Part-II of the VB6 File Handling tutorial series if you wish to read about Access Permissions and Locks. Read Section VII : ACCESS-LOCKS for more information on Locks and Access Permissions for Sequential Files.
To open a File in Sequential Mode, we need to use the Open Command like this:
Open <FILENAME> For <MODE> As <FILE#> FILENAME : Contains the Path of the File to be opened. MODE : Can be INPUT, OUTPUT or APPEND FILE# : Any number from 1 to 255 preceded by a #
Each File irrespective of its mode requires a file handle(FILE#). All operations
on the file are done using the File Handle. The File Handle can be any number
from 1 to 255, and this number is preceded by the # character.
Files can be opened in three modes in Sequential File Handling Mode and they are
used in different situations as shown.
INPUT -> Used to Read From a File.
OUTPUT -> Used to Write to a File.
APPEND -> Used to Write to a File.
Hence, to open a file Contacts.txt in Input Mode we use the Open Command like
Open "C:\Contacts.txt" For Input as #1
Notice that the path of the file is mentioned. If the path is not mentioned,
Visual BASIC assumes the file to be in the current directory.
To close the file we use the CLOSE Command like this:
Close #1
This Closes the File referred to by File Handle 1. The Close Command can also be
called with no arguments, but in this case it would close all open Files.
NOTE: Closing a File is mandatory after your I/O operations are completed. Not
closing a file can lead to loss of data.
For the rest of this section, assume the Contacts.txt file to contain the
following data:
"Sanchit",9811122233 "Friend",9812345634 "Enemy",9821630236
Now let us try to read from this file. We can read each line separately into a
string by using the Line Input Command. Take a look at this snippet:
Dim tmp as String Open "C:\Contacts.txt" For Input as #1 Line Input #1, tmp Close #1 Msgbox tmp
As you can see, the MessageBox displays: "Sanchit",9811122233
The Line Input Command extracts the line currently pointed to by the File
Pointer (this happens internally) into a string.
If we add another Line Input Command after the first, the MessageBox will
display: "Friend",9812345634
We can now write a Program that displays the entire contents of a file in a
MessageBox, using the Line Input Command.
Dim tmp as String, contents as String Open "C:\Contacts.txt" For Input as #1 While Eof(1) = 0 line input #1,tmp contents = contents + tmp Wend Close #1 Msgbox contents
The Output is: "Sanchit",9811122233"Friend",9812345634"Enemy",9821630236
The Eof() Function (Discussed in Section V.) determines if the End of the
specified file has been reached.
If you look at the original file, there are newline characters after every entry.
But when we use Line Input or any other Sequential Mode Function, the Newline
character is never considered. Hence the Output shown is without the Newline
Now what if we wanted to separate the two fields and store the Name and Phone
Number into two variables?
We certainly can, with the help of the Input #<File> Command.
To separate the two fields into two variables we can use it like this:
Input #1, strname, lngphone Msgbox "Name = "+strname Msgbox "Phone = "+Str(lngphone)
SYNTAX :Input #<file_handle> , <var1>, [var2], ... , [varN]
To use the Input# Command, we must know the exact number and type of fields
present in a data file. Remember that in case the argument types are mismatched,
it results in an Error.
That's all there is to read a file in Sequential Mode. Now let us turn our
attention to writing data into a file.
As we have seen earlier, there are two modes for writing data into a file,
OUTPUT mode and APPEND mode.
The OUTPUT Mode creates a new file irrespective of whether a file with the same
name exists or not. In other words, If no file by the specified filename is
present, a new file is created else the previous file is overwritten (rather
deleted and a new file with the same name is created).
The APPEND Mode does exactly what the OUTPUT Mode does but with a difference. It
can also create a file if it doesn't exist in the directory. But if the file is
present, it adds data (provided by the programmer) to the end of the file. This
means that we can add new information without destroying the information that
was present before.
This mode can be used in a Web-Access Logger Program. Everytime a User accesses
a webpage, the program can add the visitor's IP Address to a given file. If the
OUTPUT Mode was used in this case, only the most recent visitor's IP Address
would be stored in the file.
Unlike Reading from Files which is done by using only the Input# Command,
Writing to a File can be accomplished by using two commands, Print# and Write#.
Their Syntax is exactly like that of the Input# Command.
Consider the following code snippet:
Open "C:\names_database.txt" For Output As #1 Print #1, "My Phone number is 12345678", 910 Write #1, "My Phone number is 12345678", 910 Close #1 End
If you open the names_database.txt file in a Text-Editor you will see the
contents of the file as follows:
My Phone number is 12345678 910 "My Phone number is 12345678",910
With Print#, what appears in the file would be the exact image of what
would appear on the screen (i.e. No quotes around strings and no commas)
In this case the file will contain the string:"My Phone number is 12345678"
followed by 2 spaces, numeral 9, numeral 1, numeral 0, another space followed by
two characters (0xD 0xA) That make up the Carriage Return/Line Feed Combination.
The Write# Command Writes Strings into the File with the Quotes, Numbers
as they are and separates different fields by using a comma.
It is good practice to use this command instead of Print# since the Input#
Command is able to separate Records into Fields from Records that are written by
the Write# Command. (It can work with Print# too, but it requires additional
code and yet may not work as expected)
We must remember one important thing about Print# and Write#. After every Print#
or Write# Command, the respective command automatically inserts a Carriage
Return/Line Feed Characters (0xD 0xA) and hence every subsequent Write# or Print#
Command will write data to the next line in the file. If you wish to write data
on the same line in the file, add it to the same Print#/Write# Command.
Write #1,"ABCD" Write #1,123 Write #1,"ABCD",123
Write# has a major advantage over Print# when it comes to Storage of Strings.
In the previous example, the string:"My Phone number is 12345678" was stored as
"My Phone number is 12345678 " (with two additional spaces) by using Print#.
Sometimes 7 Additional Spaces are stored, at times 3 or 5 and the number varies
with each string. Hence it becomes difficult to figure out if the 'additional'
spaces are actually a part of the string or are added by VB itself. This also
makes it difficult to separate a record into different fields.
The Write# Command on the other hand stores the entire string within
quotes, so there is no doubt about the content as well as the length of the
MSDN offers the same advice.
If, at some future time, you want to read the data from a file using the Input#
statement, use the Write # statement instead of the Print # statement to write
the data to the file. Using Write# ensures the integrity of each separate data
field by properly delimiting it, so it can be read back in using Input#.
Using Write# also ensures it can be correctly read in any locale.
statement, use the Write # statement instead of the Print # statement to write
the data to the file. Using Write# ensures the integrity of each separate data
field by properly delimiting it, so it can be read back in using Input#.
Using Write# also ensures it can be correctly read in any locale.
But incase you are wondering why the number of additional spaces keep changing
each time, here is the reason why it happens.
Unlike Languages such as C/C++,Java etc. where the length of a string has to be
specified beforehand, Visual Basic does not force the Programmer to do this.
If the Programmer does not specify the length of the string at compile time,
Visual Basic has its own way of allocating memory based on the strings contents.
Click here to see how Strings are internally stored in VB6.
As a result, extra memory may get allocated which results in the additional
spaces in the data files.
You can remove this shortcoming by either using Write# or by providing the
length of the string at compile time. The Syntax to do this is:
Dim <variable_name> As String * <Length_of_String>
- FreeFile()
DESCRIPTION : Returns an Integer representing the nextfile number available
for use by the Open statement.
SYNTAX : FreeFile[(rangenumber)]
The optional rangenumber argument is a Variant that specifies
the range from which the next free file number is to be
returned. Specify a 0 (default) to return a file number in the
range 1 – 255, inclusive. Specify a 1 to return a file number
in the range 256 – 511.
USE : FreeFile() is used to avoid using a file handle that is already
in use.
DESCRIPTION : Returns anInteger containing the Boolean value True when the
end of a file opened for sequential Input has been reached.
SYNTAX : EOF(filenumber)
The required filenumber argument is an Integer containing any
valid file number.
USE : EOF() is occasionally used in loops to process a file until the
End of File is reached.
- FileLen()
DESCRIPTION : Returns a Long specifying the length of a file in bytes.
SYNTAX : FileLen(pathname)
The required pathname argument is a string expression that
specifies a file.
USE : FileLen() is Used to find the length of a file that has not
been opened using the Open Command.
DESCRIPTION : Returns a Long representing the size, in bytes, of a file
opened using the Open statement.
SYNTAX : LOF(filenumber)
The required filenumber argument is an Integer containing a
valid file number.
USE : LOF() is used to find the length of a file when a file is
currently open.
- Seek()
DESCRIPTION : Returns a Long specifying the current read/write position
within a file opened using the Open statement.
SYNTAX : Seek(filenumber)
The required filenumber argument is an Integer containing a
valid file number.
USE : Seek() is used to get the Byte Position where the Next
Operation will take place.
That is all you need to know about Sequential File Handling.
I shall now mention few examples which use File Handling Techniques to help
you understand it better.
1) Getting the Number of Lines in a File.
Dim counter As Long, tmp As String counter = 0 Open "c:\names_database.txt" For Input As #1 While Not EOF(1) Line Input #1, tmp counter = counter + 1 Wend Close #1 MsgBox counter ' Outputs the Number of Lines in a File.
2) Deleting a Record From a File (Using Delete...Rename Method)
ASSUMPTION : The File test.txt contains:
"Sanchit", "Karve"
"Steve", "Jackson"
Dim delFirstName As String ' String that contains Record to be Deleted Dim fName As String, lName as String delFirstName = "Sanchit" Open "c:\test.txt" For Input As #1 Open "c:\test.tmp" For Output As #2 While Not EOF(1) Input #1, fName, lName If fName <> delFirstName Then Write #2, fName, lName End If Wend Close #1, #2 Kill ("c:\test.txt") ' Deletes the Original File Name "c:\test.tmp" As "c:\test.txt" ' Renames the New File
3)Deleting a Record From a File (Using Arrays Only Method)
ASSUMPTION : The File test.txt contains:
Dim strdelstring As String, tmp As String Dim file_length As Long, i as Long strdelstring = "Steve" file_length = 0 Open "C:\test.txt" For Input As #1 ' First We Find the Number of Records so that we can allocate an Array ' To Accomodate all records While Not EOF(1) Line Input #1, tmp file_length = file_length + 1 Wend Close #1 ' Now allocate the Array ReDim arrdata(file_length) As String ' And Store the Entire File's Contents into the Array Open "c:\test.txt" For Input As #1 For i = 1 To file_length Input #1, arrdata(i) Next i Close #1 ' Now Open the Same File Again in Output Mode and Write the Contents ' Back into the File except that which is supposed to be deleted. Open "c:\test.txt" For Output As #1 For i = 1 To file_length If arrdata(i) <> strdelstring Then Write #1, arrdata(i) End If Next i Close #1
4) Storing/Reading a User Defined Type in a String
Dim x As Student, y As Student x.name = "Nerd" x.age = 18 x.grade = "A+" y.name = "Dunce" y.age = 18 y.grade = "F" Open "c:\test.txt" For Output As #1 Write #1, x.name, x.age, x.grade Write #1, y.name, y.age, y.grade Close #1
Dim x As Student, y As Student Open "c:\test.txt" For Input As #1 Input #1, x.name, x.age, x.grade Input #1, y.name, y.age, y.grade Close #1 MsgBox x.name + " " + Str(x.age) + " " + x.grade MsgBox y.name + " " + Str(y.age) + " " + y.grade
The following table lists the errors most common to file-handling operations,
along with their error codes and likely causes.
52 Bad file name or number. (File Handle already in use)
53 File not found. (File may not exist or probably a typo)
54 Bad File Mode. (Using Input# when File open in Output/Append Mode
or using Print#/Write# when File open in Input Mode)
55 File Already Open. (You have forgotten to close the file before
opening it again.)
57 Device I/O Error. (Hardware fault. Check your Hard disk.)
58 File already Exists.
59 Bad Record Length. (Only for Random Access Files)
61 Disk Full (No free space on disk drive)
62 Input past end of file. ( A file is being read even after the EOF
has been reached. Check if the Eof()
Condition is placed and used correctly.)
63 Bad Record Number. (Only for Random Access Files)
67 Too many files at the same time. (Too many files are currently open)
68 Device unavailable.
70 Permission Denied. (Disk is write-protected.)
71 Disk not Ready.
74 Can't rename files across different drives
75 Path/File Access Error
76 Path Not Found.
52 Bad file name or number. (File Handle already in use)
53 File not found. (File may not exist or probably a typo)
54 Bad File Mode. (Using Input# when File open in Output/Append Mode
or using Print#/Write# when File open in Input Mode)
55 File Already Open. (You have forgotten to close the file before
opening it again.)
57 Device I/O Error. (Hardware fault. Check your Hard disk.)
58 File already Exists.
59 Bad Record Length. (Only for Random Access Files)
61 Disk Full (No free space on disk drive)
62 Input past end of file. ( A file is being read even after the EOF
has been reached. Check if the Eof()
Condition is placed and used correctly.)
63 Bad Record Number. (Only for Random Access Files)
67 Too many files at the same time. (Too many files are currently open)
68 Device unavailable.
70 Permission Denied. (Disk is write-protected.)
71 Disk not Ready.
74 Can't rename files across different drives
75 Path/File Access Error
76 Path Not Found.
You can use an Error Handler to check for these errors using the Err.Number
Property like this:
On Error Goto err_handler 'code that may result in an error err_handler: Select Case Err.Number Case 53: Msgbox "File Not Found" Case 55: Msgbox "File Already Open" Case 71: Msgbox "Disk Not Ready" End Select Resume Next
You can download the second part of this tutorial that deals with Binary File Handling here and the third part which discusses Random Access Files here.
Keep Checking the Tutorials Section for Updates.
You can email me suggestions/mistakes or anything else that you would like to
add to born2c0de AT dreamincode.net
To clarify doubts and ask questions you can also PM me or Post a Reply by
clicking:"Add Reply" below.
*New* UPDATES
Part-II of the Tutorial is finally here.
I advise you to read it, because it includes a section on Access Permissions and Locks for networked environments, which also applies to sequential files.
Click here for the next part on Binary File Handling.


text:
Officers with the Scott County Sheriff's Department and an Indiana State Police forensic evidence team have recovered the presumed remains of Paul Graupe, an Austin resident who disappeared two days before Thanksgiving in 2009.
The missing man has been the subject of numerous searches by local police since his disappearance was reported by family members on November 26, 2009. No one has seen the slightly-built, dark-haired Graupe since the afternoon of November 24, 2009, when he reportedly said he planned to visit a man who owed him some money.
A tip provided to the Sheriff's Department on Tuesday, November 20, allowed the department to request a search warrant for the residence and outbuildings of Mr. and Mrs. Robert L. Riley Sr., 586 West Main Street (State Road 256 West), Austin.
Through County Prosecutor Jason Mount, the search warrant was secured from Scott Circuit Court Judge Roger Duvall, and Sheriff Dan McClain assembled a team in the late afternoon. His team included the two ISP technicians, Chief Deputy Donald Campbell, Detective Rick Barrett, Deputies Jeremy Arnold and Rodney Rudder and Reserve Deputy Jack Sanders.
An arrest warrant for Robert L. "Bobby" Riley Jr., 39, was also issued that same day out of Scott Superior Court for nonsupport of a dependent. The younger Riley was reported to be over $2,000 behind in child support payments.
Upon the team's arrival at the Riley home just before 5:30 p.m., Bobby Riley was taken into custody without incident and transported to the Scott County Security Center in Scottsburg. The remaining family members were advised to leave the premises, and the home and grounds were secured by officers in preparation for a search.
No evidence was recovered from the family's home. The team then concentrated its efforts on a small duplex immediately behind the house. Reportedly, the structure had once been used as a rental unit, but no one had occupied the building since Graupe's disappearance.
Entering the building, officers found the structure in poor physical condition and filled with junk. Sheriff McClain said it took at least two hours to work through items piled in the building. The body was found in a back room, in surprisingly good condition, considering the time that had lapsed between Graupe's disappearance and its recovery.
Sheriff McClain said that Scott County Coroner Kevin Collins was notified as was Prosecutor Mount when the remains were discovered. Both arrived that evening to witness the removal of the body.
Evidence technicians collected material around the body before it was carefully removed and transported to the Kentucky Medical Examiner's Office in Louisville. Preliminary tests were performed on Wednesday, November 21, and a laminated worker's ID badge issued by the company for which Graupe worked was found in the body's clothing.
Additional testing is scheduled to be performed on Friday, November 23, by a forensic pathologist.
Officers remained on the scene that Tuesday past 11 p.m. as collection of possible evidence was performed.
On Wednesday morning, Bobby Riley's initial court hearing on the nonsupport charge, a Class D felony, was conducted in Superior Court. A not guilty plea was entered for Riley, with bond set at $25,000 and a jury trial date of February 12 scheduled.
Immediately after that hearing, Riley was taken to Circuit Court. A probable cause affidavit filed under a miscellaneous action and signed by Sheriff McClain indicated that Riley admitted to Detective Barrett and Deputy Arnold that he had stabbed Graupe and hid the body in the duplex.
Judge Duvall allowed a 72-hour hold to be placed on Riley because of the unlikelihood that proper forensic testing could be completed on the remains because of the Thanksgiving holidays. The hold order does not include holiday or weekend hours.
Riley is expected to be brought back to Circuit Court some time on Tuesday, November 27, to be formally charged,.

subset: commoncrawl


text:
Hosted by Morgan Freeman, Through the Wormhole explores the deepest mysteries of existence — the questions that have puzzled mankind for eternity.
What are we made of? What was there before the beginning? Are we really alone? Is there a creator? These questions have been pondered by the most brilliant minds of the human race. Now, science has evolved to the point where hard facts and evidence may be able to provide us with answers.--------------------------------------------------------------------
Is There a Creator?
By Nathan Chandler, HowStuffWorks.com
For centuries, philosophers and scientists have marveled at the complexity of our universe and asked a lot of hard questions. Are we the only intelligent life in the universe? Is the entire universe and life on Earth simply the chance result of a combination of physical phenomena? Or did some supreme being somehow plan and then will this universe into existence?
Many physicists and philosophers alike have argued that it's very unlikely that our universe is the product of pure chance. They insist that nature alone could not achieve the precarious balance of forces that resulted in the equilibrium of galaxies and life forms we know. They say that this finely-tuned universe was guided by a great being we have yet to understand.
Some quirky and fortunate physics came into play as these constants guided the universe's formation. For example, take the existence of carbon, which is the foundation of all life. Carbon results from the binding of three helium atoms. Statistically, creating prolific amounts of carbon is very unlikely, because each of the three atoms has slightly different energy levels that preclude the economical formation of carbon.
But the electromagnetic and strong nuclear constants level out the energy levels of the helium atoms — as a result, carbon forms. Even a tiny change in either of these constants would greatly inhibit carbon production, and thus, greatly reduce the potential for life.
Similarly, the special relationship between the weak nuclear force and gravity allowed for the preservation of hydrogen during the Big Bang, which would have otherwise transformed the hydrogen into helium. Without hydrogen, there'd be no water. Likewise, the narrowly defined initial conditions present at the birth of our universe were critical to ensuring its survival. Most scientists agree that the big bang marked the beginning of our universe, and that the forces involved in this event were calibrated with the same care as the rest of the laws
However, we can all agree that the universe is an overwhelmingly complex place. The most intelligent human minds of history have uncovered countless tantalizing clues as to our origins, but complete answers to all of our
questions still evade our understanding. Eventually, we may find that the finely tuned universe assertion offered
key insights into the existence of a super-intelligent creator. At the very least, the concepts driving these assertions confirm one thing for sure — our universe is, without a doubt, a magnificently calibrated design that won't be unraveled and fully understood anytime soon.
Views: 2192
© 2019 Atheist Nexus. All rights reserved. Admin: The Nexus Group. Powered by


text:
Prison X: The Charles Davis Story (Recalls A Deadly Fight In The Yard Where An Inmate Attempted To Fight 3 Others Off With Knife)
Please click the "Report" button below if the video on this page is not working properly.
Comments will only be displayed by verified emails. No Spamming or Racism.


text:
Sunset Stonestown Interest Form
Thanks for your interest in joining this community! Fill out this form and our leaders will be in touch.
We desire for our communities to be healthily diverse, so not every group works for every person! But don't worry, we WANT to be in community with you so we'll work hard to make it happen.


text: PHEW! Carter's 3rd birthday party was last weekend, and WOW is there a lot of stuff to remember when you're planning a party! I wasn't big on hosting parties before Carter was born, so I'm pretty new to this. But even so, being my 3rd time around on this kid's-birthday-party thing, […] Read More »