473,407 Members | 2,629 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,407 software developers and data experts.

Writing a little app to modify a file

Hello all!

I'm trying to design and write a little application for someone
in my office, but I'm having some trouble. I have the following database
structure (Note: just some sample data, obviously):

SystemNumber SystemNumberMAX SystemName SystemKey
9007404 Windows Test 1 A
9007405 Windows Test 1 A
9007406 Windows Test 1 A
9008683 Windows Test 45 A
9008684 Windows Test 45 A
9017616 Windows Test 4595bg A
9019528 Windows Test 1 B

The SystemNumberMAX field is to be populated with the maximum SystemNumber
for a group, where a group is a unique System Key and System Name combo. The
SystemNumberMAX is only to be filled when there is more than 1 System Number
for a group. Thus, when the module is complete, the above file set should
look like this:
SystemNumber SystemNumberMAX SystemName SystemKey
9007404 9007406 Windows Test 1 A
9008683 9008684 Windows Test 45 A
9017616 Windows Test 4595bg A
9019528 Windows Test 1 B
I'm totally stumped though! I've only done stuff like affecting forms and
switchboards in Access/VBA, and wrote a VB.NET tic-tac-toe game. I'm
thinking the steps are:

1. Read the file in, and split it by commas (meaning I'll ascii-delimit it
from Access first)
2. Select the max SystemNumber # for the group and write it to a variable.
3. Delete the records in the range between the minimum and maximum
SystemNumber for the group (including the record for the max SystemNumber)
4. Write the max SystemNumber into the SystemNumberMAX field.

Can anyone offer guidance or example code for something similar?

Thanks! -Mike
Nov 21 '05 #1
3 1125
Michael,

I made a sample for you that needs a datagrid,
I have made the table, however that you can read of course direct from your
access database.

\\\\
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt As New DataTable
dt.Columns.Add("Serial")
dt.Columns.Add("Name")
dt.Columns.Add("Key")
Dim dtresult As New DataTable
dtresult.Columns.Add("Serial")
dtresult.Columns.Add("SerialMax")
dtresult.Columns.Add("Name")
dtresult.Columns.Add("Key")
dt.LoadDataRow(New Object() {"9007404", "Windows Test 1", "A"},
True)
dt.LoadDataRow(New Object() {"9007405", "Windows Test 1", "A"},
True)
dt.LoadDataRow(New Object() {"9007406", "Windows Test 1", "A"},
True)
dt.LoadDataRow(New Object() {"9008683", "Windows Test 45", "A"},
True)
dt.LoadDataRow(New Object() {"9008684", "Windows Test 45", "A"},
True)
dt.LoadDataRow(New Object() {"9017616", "Windows Test 4595bg", "A"},
True)
dt.LoadDataRow(New Object() {"9019528", "Windows Test 1", "B"},
True)
Dim dv As DataView = dt.DefaultView
dv.Sort = "Name, Key"
Dim dr As DataRow
For Each drv As DataRowView In dv
If dr Is Nothing Then
dr = dtresult.NewRow
dr(0) = drv(0)
dr(1) = drv(0)
dr(2) = drv(1)
dr(3) = drv(2)

Else
If dr(2).ToString = drv(1).ToString And dr(3).ToString =
drv(2).ToString Then
dr(1) = drv(0)
Else
dtresult.Rows.Add(dr)
dr = dtresult.NewRow
dr(0) = drv(0)
dr(1) = drv(0)
dr(2) = drv(1)
dr(3) = drv(2)
End If
End If
Next
dtresult.Rows.Add(dr)
DataGrid1.DataSource = dtresult
End Sub
///

I did not really check it, however the result looks for me something what it
has to be.

I hope this helps,

Cor
Nov 21 '05 #2

One quick comment: If the data is already in Access, you should do this
with a query within Access rather than exporting and processing it. If
this is an acceptable solution just say if you want help with the query
:)

Michael D. wrote:
Hello all!

I'm trying to design and write a little application for someone
in my office, but I'm having some trouble. I have the following database structure (Note: just some sample data, obviously):

SystemNumber SystemNumberMAX SystemName SystemKey
9007404 Windows Test 1 A
9007405 Windows Test 1 A
9007406 Windows Test 1 A
9008683 Windows Test 45 A
9008684 Windows Test 45 A
9017616 Windows Test 4595bg A
9019528 Windows Test 1 B

The SystemNumberMAX field is to be populated with the maximum SystemNumber for a group, where a group is a unique System Key and System Name combo. The SystemNumberMAX is only to be filled when there is more than 1 System Number for a group. Thus, when the module is complete, the above file set should look like this:
SystemNumber SystemNumberMAX SystemName SystemKey
9007404 9007406 Windows Test 1 A
9008683 9008684 Windows Test 45 A 9017616 Windows Test 4595bg A
9019528 Windows Test 1 B
I'm totally stumped though! I've only done stuff like affecting forms and switchboards in Access/VBA, and wrote a VB.NET tic-tac-toe game. I'm thinking the steps are:

1. Read the file in, and split it by commas (meaning I'll ascii-delimit it from Access first)
2. Select the max SystemNumber # for the group and write it to a variable. 3. Delete the records in the range between the minimum and maximum
SystemNumber for the group (including the record for the max SystemNumber) 4. Write the max SystemNumber into the SystemNumberMAX field.

Can anyone offer guidance or example code for something similar?

Thanks! -Mike


Nov 21 '05 #3
Yea, it IS already in Access... Actually, it is an Excel spreadsheet that I
put into access. However, I was thinking about writing a little VB app that
they could put on their desktop, click a button to select the file, and then
output a new/fixed file for them. The reason for that is they get the data
from an outside source on a montly basis, so it's not a 1-time thing... Does
that make sense? A query or VBA module would work either though, if I have
the query, I'm good enough (JUST!) to build the vb.net app, I think...

Thanks a lot!
Mike

"Larry Lard" wrote:

One quick comment: If the data is already in Access, you should do this
with a query within Access rather than exporting and processing it. If
this is an acceptable solution just say if you want help with the query
:)

Michael D. wrote:
Hello all!

I'm trying to design and write a little application for someone
in my office, but I'm having some trouble. I have the following

database
structure (Note: just some sample data, obviously):

SystemNumber SystemNumberMAX SystemName SystemKey
9007404 Windows Test 1 A
9007405 Windows Test 1 A
9007406 Windows Test 1 A
9008683 Windows Test 45 A
9008684 Windows Test 45 A
9017616 Windows Test 4595bg A
9019528 Windows Test 1 B

The SystemNumberMAX field is to be populated with the maximum

SystemNumber
for a group, where a group is a unique System Key and System Name

combo. The
SystemNumberMAX is only to be filled when there is more than 1 System

Number
for a group. Thus, when the module is complete, the above file set

should
look like this:
SystemNumber SystemNumberMAX SystemName SystemKey
9007404 9007406 Windows Test 1 A
9008683 9008684 Windows Test 45

A
9017616 Windows Test 4595bg A
9019528 Windows Test 1 B
I'm totally stumped though! I've only done stuff like affecting

forms and
switchboards in Access/VBA, and wrote a VB.NET tic-tac-toe game. I'm

thinking the steps are:

1. Read the file in, and split it by commas (meaning I'll

ascii-delimit it
from Access first)
2. Select the max SystemNumber # for the group and write it to a

variable.
3. Delete the records in the range between the minimum and maximum
SystemNumber for the group (including the record for the max

SystemNumber)
4. Write the max SystemNumber into the SystemNumberMAX field.

Can anyone offer guidance or example code for something similar?

Thanks! -Mike


Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Fernando Perez | last post by:
Hi all, by reading through the docs, the func_closure attribute of function objects is listed as writable. Yet, nowhere does it say _how_ to write to it. I am trying to do a run-time...
6
by: Sebastian Kemi | last post by:
How should a write a class to a file? Would this example work: object *myobject = 0; tfile.write(reinterpret_cast<char *>(myobject), sizeof(*object)); / sebek
5
by: Benjamin de Waal | last post by:
Hey all, I'm trying to figure out how to directly write to a device in Windows. Basically, what I'm wanting to do is create an image of a device (specifically, a CompactFlash card that uses a...
10
by: Kristian Nybo | last post by:
Hi, I'm writing a simple image file exporter as part of a school project. To implement my image format of choice I need to work with big-endian bytes, where 'byte' of course means '8 bits', not...
2
by: melanieab | last post by:
Hi, I'm trying to store all of my data into one file (there're about 140 things to keep track of). I have no problem reading a specific string from the array file, but I wasn't sure how to...
4
by: HNguyen | last post by:
Hi, I have a Web application in ASP.NET. My Application allows the users upload files into the server after checking their user names and passwords. For each transaction, the Web program will...
8
by: Paul | last post by:
I have an application that I am tryign to modify, I never wrote the original so need help with my modifications. Currently the app reads and writes to an Access database with one table 'pupils'...
3
by: Barry Flynn | last post by:
Hi I am working with a VB 2005 program which has been converted from VB6. It writes data out to a flat file, with code like the following line WriteLine(riFileNo, "Hist", lsAssetID,...
0
by: =?Utf-8?B?QWxleA==?= | last post by:
Hi all! At the moment, I am transfering an application from Windows XP to Vista. As I would like to make the application compliant with Vista, I am having some questions: 1. ) A part of the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.