dcsimg
Results 1 to 5 of 5

Thread: formatting

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2017
    Posts
    21

    formatting

    I am really struggling with formatting my text file into a datagrid. However I am confortable with my access method (random). The only trouble I am having is that data is being stored all in one line so I am finding it very difficult to format with things like streamreader as its only ouputting the entire textfile to only one record. I will show this in with an image. I would really appreciate some advice.Name:  problem.jpg
Views: 98
Size:  8.8 KB

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    100,661

    Re: formatting

    The image is rather pointless. When you say that the data is all in one row in the grid, it's pretty clear what that means. You haven't shown us the important part, i.e. the code that produces that output. If you're not getting the result you want then something is wrong with the code. If we don't see that code then there's no way we can tell you what's wrong with it. An example of the input data and what you actually expect that to look like in the output grid wouldn't hurt either, although the latter may be obvious from the former.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2017
    Posts
    21

    Re: formatting

    i am using the following code
    Code:
        Private Sub AddAdmin(ByRef OneAdmin As AdminType)
            Dim NumbersOfRecords, DeletedRecordNumber As Short
            Dim Sender As System.Object
            Dim e As System.EventArgs
            'DeletedRecordNumber = FindDeletedCustomer()
            FileOpen(1, AdminFile, OpenMode.Random, , , Len(OneAdmin))
    
            If DeletedRecordNumber <> 0 Then
                FilePut(1, OneAdmin, DeletedRecordNumber)
            Else
                NumbersOfRecords = LOF(1) / Len(OneAdmin)
                FilePut(1, OneAdmin, NumbersOfRecords + 1)
    
            End If
            FileClose(1)
    
    
        End Sub
    this is adding admins function

    i will shorten it by showing only the admin id section even tho there are other data which is collected

    Code:
     Private Sub Btn_AddNewAdmin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_AddNewAdmin.Click
    
    
            Dim OneAdmin As AdminType
            Dim AdminID As String
            Dim AdminDeleted As Boolean
            Dim Duplicate As Boolean
            Dim Responce As Short
    
            AdminFile = "Admin.dat"
            If Btn_AddNewAdmin.Text = "Add Admin" Then
                If Tbx_AdminID.Text.Length = 10 Then
                    AdminID = Tbx_AdminID.Text
                    Duplicate = ChkDpAdmin(AdminID)
    
    
                    If Not Duplicate Then
                        If (Tbx_AdminID.Text <> "")
                            OneAdmin.AdminID = Tbx_AdminID.Text


    ive tried using streamreader and it just doesnt produce the padding i want with the sections split

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    100,661

    Re: formatting

    I'm afraid that I'm not going to help when the code uses that old VB6 style of I/O. I don't use that so I don't know all the ins and outs and I don't want to know. If you used a StreamReader and it didn't work then the code you wrote was wrong. I could help with that. You still haven't really provided a full and clear description of what you're trying to achieve either. I'll leave it there.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    5,630

    Re: formatting

    Quote Originally Posted by jmcilhinney View Post
    I'm afraid that I'm not going to help when the code uses that old VB6 style of I/O. I don't use that so I don't know all the ins and outs and I don't want to know. If you used a StreamReader and it didn't work then the code you wrote was wrong. I could help with that. You still haven't really provided a full and clear description of what you're trying to achieve either. I'll leave it there.
    I already gave him code to read and write data without all that random access mess from VB6 in another thread. You can check out that thread here. What he wants is actually very very simple and I explained how to do it but I got the impression he lacked a basic understanding of programming concepts. You and Sitten are better at explaining stuff to people new to programming than I am. Maybe you guys could help him where I failed.

    He wants to know how to read records from a file, display them in a DataGridView and save any changes made to any of the rows back to the file. Very basic stuff.
    Last edited by Niya; Dec 17th, 2017 at 09:44 PM.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena


    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. -jmcilhinney

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width