Private Sub Command1_Click()
    Dim a, b, cc As Integer
    Dim p(3), d(3), e(3), t(3), h(3), w(3), c(3), f(6) As Integer
    If Text4.Text <> "" Then
        strfile = Text4.Text
        Open strfile For Input As #1
        For i = 1 To 3
            Input #1, p(i), d(i), h(i), w(i)
        Next i
        Close #i
        For i = 1 To 3
            p(i) = CInt(InputBox("enter pros.tj " & CStr(i), "prosseng time for job"))
            d(i) = CInt(InputBox("enter due date " & CStr(i), "due date for job"))
            h(i) = CInt(InputBox("enter cost ear " & CStr(i), "cost of earlness"))
            w(i) = CInt(InputBox("enter weigh " & CStr(i), "weigh of job"))
        Next i
        Open "c:\machineporb.text" For Output As #2
        For i = 1 To 3
            Print #2, p(i); d(i); h(i); w(i)
        Next i
        Close #2
    End If
    For i = 1 To 3
        c(i) = 0
        e(i) = 0
        t(i) = 0
    Next i
    For i = 1 To 3
        If i <> 1 Then c(i) = c(i - 1) + p(i)
        If i = 1 Then c(i) = p(i)
    Next i
    For i = 1 To 3
        If (d(i) - c(i)) > 0 Then
            e(i) = d(i) - c(i)
            If (c(i) - d(i)) > 0 Then
                t(i) = c(i) - d(i)
    Next i
    a = 10

    For i = 1 To 3
        f(i) = h(i) * (d(i) - p(i))
        If f(i) < a Then
            a = f(i)
            Text1.Text = CStr(i)
        End If
    Next i
    a = f(1) + (h(2) * e(2)) + (w(2) * t(2))
    b = f(2) + (h(1) * e(1)) + (w(1) * t(1))
    If a > b Then f(4) = b
    If b > a Then f(4) = a
    a = f(1) + (h(3) * e(3)) + (w(3) * t(3))
    b = f(3) + (h(1) * e(1)) + (w(1) * t(1))
    If a > b Then f(5) = b
    If b > a Then f(5) = a
    Text2.Text = "12"
    a = f(2) + (h(3) * e(3)) + (w(3) * t(3))
    b = f(3) + (h(2) * e(2)) + (w(2) * t(2))
    If a > b Then f(6) = b
    If b > a Then f(6) = a
    a = f(4) + (h(3) * e(3)) + (w(3) * t(3))
    b = f(5) + (h(2) * e(2)) + (w(2) * t(2))
    cc = f(6) + (h(1) * e(1)) + ((w1) * t(1))
    If (b > a) And (cc > a) Then f(7) = a
    Text3.Text = "213"
    If (a > b) And (cc > b) Then f(7) = b
    Text3.Text = "321"
    If (cc > b) And (a > cc) Then f(7) = cc
    Text3.Text = "123"


    If b > a Then f(6) = a




End Sub

Private Sub Command2_Click()
    st = InputBox("åá ÊÑíÏ ÍÝÙ ÇáÈíÇäÇÊ")
    Open st For Output As #1
    Open "c:\machineprob.txt" For Input As #2
    While Not EOF(2)
        Input #2, st
        Print #1, st
    End While
    Close()
    MsgBox("Êã ÇáÍÝÙ")
End Sub

the error is
next without for
this is my error but there isn't

If this is vb6, you shoul know that this:

Dim a, b, cc As Integer
Declares two variant vsriables (a and b) and one
Integer ones (cc).

The same way here:
Dim p(3), d(3), e(3), t(3), h(3), w(3), c(3), f(6) As Integer
Only the last one is an array of integers.

By the way, why not start coding your stuff giving s meaningfull name to your variables?

Cheers.

Look at lines 32-37. You open two If blocks but don't close them with End If.

Please use the Code tool to insert code so that it gets properly formatted. I fixed it for you (this time).

btw in line 10 I think you mean Close #1

As Jim said, 2 If statements opened, never closed...

guys am really happy for those amazing answers
but unfortunately my program still not work after this modifications

now it gives me a erroe that "file not found "
in line 6 ?

It means what it says. What's the mystery?

You might need more rigorous validation of the text in Text4. Perhaps using the CommonDialog to get the filename will be easier. If you're using the same pattern for the filename as for Output #2, try using '.txt' for the extension instead of '.text'. It's probably a moot point, since in lines 10-15 you load the data from the file, then immediately after that in lines 11-16 you overwrite that data, making lines 10-15 useless.

so pls guys what i suppose to do
can i upload the sourse code and check it for me
really thanks for all of u

try this way:

Private Sub Command1_Click()
    Dim a, b, cc As Integer
    Dim p(3), d(3), e(3), t(3), h(3), w(3), c(3), f(6) As Integer
    If Text4.Text <> "" Then

        strfile = Text4.Text
        If Dir(strfile) = "" Then
          MsgBox ("Could not find " & strfile & " file on disk")
          Exit Sub
        End If

        Open strfile For Input As #1
        For i = 1 To 3
            Input #1, p(i), d(i), h(i), w(i)
        Next i
        Close #1
        For i = 1 To 3
            p(i) = CInt(InputBox("enter pros.tj " & CStr(i), "prosseng time for job"))
            d(i) = CInt(InputBox("enter due date " & CStr(i), "due date for job"))
            h(i) = CInt(InputBox("enter cost ear " & CStr(i), "cost of earlness"))
            w(i) = CInt(InputBox("enter weigh " & CStr(i), "weigh of job"))
        Next i
        Open "c:\machineporb.text" For Output As #2
        For i = 1 To 3
            Print #2, p(i); d(i); h(i); w(i)
        Next i
        Close #2
    End If
    For i = 1 To 3
        c(i) = 0
        e(i) = 0
        t(i) = 0
    Next i
    For i = 1 To 3
        If i <> 1 Then c(i) = c(i - 1) + p(i)
        If i = 1 Then c(i) = p(i)
    Next i
    For i = 1 To 3
        If (d(i) - c(i)) > 0 Then
            e(i) = d(i) - c(i)
            If (c(i) - d(i)) > 0 Then
                t(i) = c(i) - d(i)
    Next i
    a = 10
    For i = 1 To 3
        f(i) = h(i) * (d(i) - p(i))
        If f(i) < a Then
            a = f(i)
            Text1.Text = CStr(i)
        End If
    Next i
    a = f(1) + (h(2) * e(2)) + (w(2) * t(2))
    b = f(2) + (h(1) * e(1)) + (w(1) * t(1))
    If a > b Then f(4) = b
    If b > a Then f(4) = a
    a = f(1) + (h(3) * e(3)) + (w(3) * t(3))
    b = f(3) + (h(1) * e(1)) + (w(1) * t(1))
    If a > b Then f(5) = b
    If b > a Then f(5) = a
    Text2.Text = "12"
    a = f(2) + (h(3) * e(3)) + (w(3) * t(3))
    b = f(3) + (h(2) * e(2)) + (w(2) * t(2))
    If a > b Then f(6) = b
    If b > a Then f(6) = a
    a = f(4) + (h(3) * e(3)) + (w(3) * t(3))
    b = f(5) + (h(2) * e(2)) + (w(2) * t(2))
    cc = f(6) + (h(1) * e(1)) + ((w1) * t(1))
    If (b > a) And (cc > a) Then f(7) = a
    Text3.Text = "213"
    If (a > b) And (cc > b) Then f(7) = b
    Text3.Text = "321"
    If (cc > b) And (a > cc) Then f(7) = cc
    Text3.Text = "123"
    If b > a Then f(6) = a
End Sub
Private Sub Command2_Click()
    st = InputBox("åá ÊÑíÏ ÍÝÙ ÇáÈíÇäÇÊ")
    If Dir("c:\machineprob.txt") = "" Then
          MsgBox ("Could not find c:\machineprob.txt file!")

          Exit Sub
     End If

    Open st For Output As #1

    Open "c:\machineprob.txt" For Input As #2
    Do While Not EOF(2)
        Input #2, st
        Print #1, st
    Loop
    Close #1
    Close #2
    MsgBox ("Êã ÇáÍÝÙ")
End Sub

thanks Cimpery for ur help but still not work ?
pls can i send to u the sourse code and check it by urlf ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.