How JustAnswer Works:
  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site. Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.
Ask Chris Baxter Your Own Question
Chris Baxter
Chris Baxter, Programming Tutor
Category: Programming
Satisfied Customers: 250
Experience:  Completed BSIT concentration Software Engineering, tutored other students and classmates in Java and, C++, and Obj C.
Type Your Programming Question Here...
Chris Baxter is online now
A new question is answered every 9 seconds

Ingo U, how are you? I would like you to make me a

Customer Question

Hello Ingo U, how are you? I would like you to make me a simple Random Access program to write simple data such name, address, state, zip.
And I would like a similar Random Access program to read the data as well.
I also need to know how to add data and remove data from the file and also how to delete the Random data file from the disk.
I also need to know how to display it.
I will figure out myself how to create my own program from what I learn from the program that you write for me.
Hope it is not too much trouble.
Thanks *** ********
Submitted: 1 year ago.
Category: Programming
Expert:  Ingo U replied 1 year ago.
Hello Ken,welcome back, I'll be happy to try and help you. So it sounds like you're looking for a basic contact info manager code sample?When you say "Random Access", why did you choose those words specifically? If you can write down some examples or scenarios of how a user would interact with this program, so called "use cases", that would help.For example, something like this:a) Ken wants to store contact info for his buddy Ingo. He pulls up the program, clicks on the "New" button, and fills out the form with Ingo's contact info. He clicks "save" and the new information is stored in his data file "contacts.txt"b) Ken wants to find the contact info for his boss George. He pulls up the program, clicks the "FInd" button, and puts George's last name in the box. He clicks "GO' and the program looks for the information in the data file. If found, it shows it, otherwise it displays an error. If there are multiple entries for George's last name, it tells you so and asks to provide more information to narrow the search.c) ...d)... etc etcYou get the idea? Those are just sample ideas... we like to start with something to help us visualize what we're looking at and doing with it when it's all done... or at least a first version of it.
Customer: replied 1 year ago.
Yes, I meant a Visual Basic Random Access File. I want to create one that I need in my program. I had a working one but I have loss it when my computer system was repaired in Dec 2015. Examples
enter first name = FName
enter Last name =Lname
I need to know how to setup a Random file system in VB use it as a data file system (simple system). It has been sometime
sense I have attempted it. I forgot, perhaps your program will bring back my memory of how to do it.
Customer: replied 1 year ago.
i don't know a better example
Expert:  Ingo U replied 1 year ago.
My apologies,I am out of ideas on this one at the moment.I am opting out and opening the question up to other professionals here who may be able to help.Regards,Ingo U
Customer: replied 1 year ago.
OK, thanks
I know random files are used anymore but I lost my working copy that I had. It has been a while.
Expert:  Chris Baxter replied 1 year ago.
Hello!Such a program is a bit complex, but I think I can talk you through it. First off, in vb, you simply want to create a windows program? If so, you simply want to create a blank project. Go to the designer, and drag and drop your items from the toolbox on the left of the screen. You can get your buttons and applicable display fields, and place them on the form for the main program screen. Once this is done, each object will be called "button1" or "label1" "button2" and so on. You can change these names of objects in the properties box usually located in the bottom left corner of the screen, scroll to "name" to change what the object is called, and scroll to "text" to change what is shown. To do that programmatically, you will have your code:textbox1.Text = "this string"Since all display text boxes display string values, input from them would need to be managed by transferring the strings to number values if necessary, and if not, then simply store the strings in an array or array of arrays. To write data to a text file, you would simply output the string values of each of the boxes on the screen to the file, either delimited by comma or by carriage return (enter button).I have written quite a few of these. You can have the program read and write, or divide those into separate modules. The website below has a bit of code you are looking for, the complete address book code project is downloadable as well as valuable information on coding VB6. As I do not know which version of VB you are using to develop, I cannot create a program that will be guaranteed to open on your system. the following link for a video tutorial on what you are trying to do, complete with steps to insert your database, and search functions. finally, the easiest method to save the file is pop the saveFileDialog and allow the user to select where to save, then save all data in the dataGridView of the database to the text file, some relevant code, if you read the thread, at the following link!
Customer: replied 1 year ago.
Thank you Chris, I appreciate your help. I am not exactly a novice programmer. I program for my enjoyment at my level of knowledge which is not that good. I have followed VB ever since it was in release 3. Because I don’t use Random Access files that often, I have for gotten how they work and how to use them correctly. Here is an example of my program structure and program. However, I cannot get the program to add data to the file and I don’t know how to delete a record from the file .
Public RecordNum As Integer
Public TodayDate As Date
Public CatName As String
Public VideoName As String
Public ComName As String
Public ULData As String
End StructureDim RecNum As Integer
Vfilenum = FreeFile()
RecLenght = Len(VideoRecords)
FileOpen(Vfilenum, "C:\VCollection.Dat", OpenMode.Random, OpenAccess.ReadWrite, , RecLenght)
VideoRecords.Recount = VideoRecords.Recount + 1
RecNum = VideoRecords.Recount
'RecNum = VideoRecords.LastRecord
VideoRecords.CatName = Label5.Text
VideoRecords.VideoName = Label6.Text
VideoRecords.ComName = TextBox1.Text
VideoRecords.ULData = TextBox2.Text
VideoRecords.TodayDate = Format(Now(), "D")'LastRecord = LastRecord + 1
'RecNum = RecNum + 1
FilePut(Vfilenum, VideoRecords, RecNum)
Expert:  Chris Baxter replied 1 year ago.
I can debug if you can send me your full raw code. I do not need to see the interface, you have your text boxes and all labeled well enough, I am building a new code but some things are undeclared on your sample here, and I want to be sure to be able to provide you the solution to the issue.Removing a record from the text file you save to is as easy as an array element manipulation, where you laid the elements, you shift them as needed programmatically in the array, and then you output a save file with the same name set to overwrite the original. Easy enough and fair user interface to pop "you already have a save file would you like to overwrite?" and give the user the option, but then you have to code a decision as to which save file will be used to load, if you end up allowing the user to save more than one.