Click here to Skip to main content
15,897,518 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Count Similar Lines Pin
vijay24821-Apr-09 4:49
vijay24821-Apr-09 4:49 
GeneralRe: Count Similar Lines Pin
_Damian S_1-Apr-09 15:20
professional_Damian S_1-Apr-09 15:20 
GeneralRe: Count Similar Lines Pin
Tom Deketelaere1-Apr-09 20:57
professionalTom Deketelaere1-Apr-09 20:57 
GeneralRe: Count Similar Lines Pin
C#Coudou1-Apr-09 15:35
C#Coudou1-Apr-09 15:35 
GeneralRe: Count Similar Lines Pin
C#Coudou1-Apr-09 15:37
C#Coudou1-Apr-09 15:37 
GeneralRe: Count Similar Lines Pin
vijay24821-Apr-09 21:00
vijay24821-Apr-09 21:00 
GeneralRe: Count Similar Lines Pin
Eddy Vluggen1-Apr-09 1:47
professionalEddy Vluggen1-Apr-09 1:47 
GeneralRe: Count Similar Lines Pin
vijay24821-Apr-09 2:04
vijay24821-Apr-09 2:04 
this is the code i have written sofar.
Private Function Groupe_Flex_Cable()
        Dim temp As String
        Dim name As String
        Dim comp As String
        Dim desF As String
        Dim desAF As String
        Dim desA As String
        Dim desAA As String
        Dim ecn As String
        Dim dnf As String
        Dim repDNF As String
        Dim repASM As String
        Dim NbOfSpaces As Integer = 0
        Dim Grp As Boolean = False
        Dim a As String = "  "
        Dim b As String = "       "
        Dim l As Integer
        Dim lpFlex As Integer = 0
        Dim lpCable As Integer = 0
        Dim Nb As Integer = 2
        Dim Current_desf As String = ""
                Try
            Using sw As StreamWriter = New StreamWriter("c:\DB\output11.txt")
                Using sa As StreamReader = New StreamReader("c:\DB\01530501.txt")
                    temp = sa.ReadLine()
                    name = temp.Substring(0, 29)
                    comp = temp.Substring(30, 18)
                    desF = temp.Substring(49, 32)
                    desAF = temp.Substring(82, 38)
                    desA = temp.Substring(120, 35)
                    desAA = temp.Substring(156, 33)
                    ecn = temp.Substring(190, 10)
                    dnf = temp.Substring(201, 7)
                    repDNF = temp.Substring(208, 9)
                    repASM = temp.Substring(217, 8)
                    sw.WriteLine(name & comp & desF & desAF & desA & desAA & ecn & dnf & repDNF & repASM)
                    sw.WriteLine(sa.ReadLine())
                    While sa.Peek() >= 0

                        temp = sa.ReadLine()
                        name = temp.Substring(0, 29)
                        comp = temp.Substring(30, 18)
                        desF = temp.Substring(49, 32)
                        desAF = temp.Substring(82, 38)
                        desA = temp.Substring(120, 35)
                        desAA = temp.Substring(156, 33)
                        ecn = temp.Substring(190, 10)
                        dnf = temp.Substring(201, 7)
                        repDNF = temp.Substring(208, 9)
                        repASM = temp.Substring(217, 8)


                        If name.Contains("Groupe") Then
                            Grp = True
                            NbOfSpaces = NbOfCar(name, " ") + 2
                        ElseIf Grp And NbOfCar(name, " ") = NbOfSpaces Then
                            sw.WriteLine(name.Remove(0, 2) & comp.Insert(0, a) & desF & desAF & desA & desAA & ecn & dnf & repDNF & repASM)
                        Else
                            Grp = False
                                                      
                            lpFlex = name.IndexOf("_FLEX")
                            lpCable = name.IndexOf("_CABLE")

                             If lpFlex <> -1 Or lpCable <> -1 Then

                                l = name.IndexOf(".")
                                If lpCable = -1 Then
                                    sw.WriteLine(name.Substring(0, lpFlex) & name.Substring(l, (name.Length - l)) & comp.Insert(0, b) & desF & desAF & desA & desAA & ecn & dnf & repDNF & repASM)
                                Else
                                    sw.WriteLine(name.Substring(0, lpCable) & name.Substring(l, (name.Length - l)) & comp.Insert(0, b) & desF & desAF & desA & desAA & ecn & dnf & repDNF & repASM)
                                End If
                                Current_desf = Trim(desF)
                                temp = sa.ReadLine()
                                Do While Current_desf = Trim(desF)
                                    name = temp.Substring(0, 29)
                                    desAF = temp.Substring(82, 38)
                                    desA = temp.Substring(120, 35)
                                    desAA = temp.Substring(156, 33)
                                    ecn = temp.Substring(190, 10)
                                    dnf = temp.Substring(201, 7)
                                    repDNF = temp.Substring(208, 9)
                                    repASM = temp.Substring(217, 8)
                                    comp = temp.Substring(30, 18)
                                    desF = temp.Substring(49, 32)
                                    temp = sa.ReadLine()
                                Loop
                                l = name.IndexOf(".")
                                If l <> -1 Then
                                    sw.WriteLine(name.Substring(0, l) & name.Substring(l, (name.Length - l)) & comp & desF & desAF & desA & desAA & ecn & dnf & repDNF & repASM)
                                Else
                                    sw.WriteLine(name)
                                End If
                            Else
                                l = name.IndexOf(".")
                                If l <> -1 Then
                                    sw.WriteLine(name.Substring(0, l) & name.Substring(l, (name.Length - l)) & comp & desF & desAF & desA & desAA & ecn & dnf & repDNF & repASM)
                                    
                                End If
                            End If
                        End If
                    End While

                End Using
            End Using
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Function

it will read a file, search for the word "Groupe" move the lines below "Groupe" towards left by 2 space characters...
then checks for _Flex or _Cable and deletes the lines below that line...

so reading a file is not a problem...

i dont know how to put it into a data table and group the similar lines and write it as a single line and enter a new fieldname called Quantity and enter the value of similar lines in the Quantity field...
GeneralRe: Count Similar Lines Pin
Eddy Vluggen1-Apr-09 2:45
professionalEddy Vluggen1-Apr-09 2:45 
GeneralRe: Count Similar Lines Pin
vijay24821-Apr-09 2:55
vijay24821-Apr-09 2:55 
GeneralRe: Count Similar Lines Pin
Eddy Vluggen1-Apr-09 3:14
professionalEddy Vluggen1-Apr-09 3:14 
AnswerRe: Count Similar Lines Pin
0x3c01-Apr-09 0:34
0x3c01-Apr-09 0:34 
AnswerRe: Count Similar Lines Pin
Jon_Boy1-Apr-09 6:07
Jon_Boy1-Apr-09 6:07 
QuestionSearch Listbox Pin
svanwass31-Mar-09 11:49
svanwass31-Mar-09 11:49 
AnswerRe: Search Listbox Pin
Christian Graus31-Mar-09 15:03
protectorChristian Graus31-Mar-09 15:03 
GeneralRe: Search Listbox Pin
svanwass1-Apr-09 10:29
svanwass1-Apr-09 10:29 
QuestionAn error occurred while performing the drop: Illegal characters in path Pin
DirtBagger31-Mar-09 11:07
DirtBagger31-Mar-09 11:07 
QuestionDynamic PropertyGrid with CheckListBox Pin
jackgreat31-Mar-09 7:05
jackgreat31-Mar-09 7:05 
QuestionSet Wallpaper Pin
Pasan14831-Mar-09 5:23
Pasan14831-Mar-09 5:23 
AnswerRe: Set Wallpaper Pin
0x3c031-Mar-09 6:39
0x3c031-Mar-09 6:39 
QuestionOn Error GoTo in VBScript Pin
ATM_Guy31-Mar-09 4:59
ATM_Guy31-Mar-09 4:59 
AnswerRe: On Error GoTo in VBScript Pin
riced31-Mar-09 5:26
riced31-Mar-09 5:26 
GeneralRe: On Error GoTo in VBScript Pin
Uros Calakovic31-Mar-09 6:57
Uros Calakovic31-Mar-09 6:57 
QuestionProblem with movetoroot from the opc da automation wrapper Pin
dadio2531-Mar-09 3:53
dadio2531-Mar-09 3:53 
AnswerRe: Problem with movetoroot from the opc da automation wrapper Pin
dadio251-Apr-09 20:47
dadio251-Apr-09 20:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.