Private Sub cmdCancel_Click()
    txtcode.Text = ""
    txtdescr.Text = ""
    txtumsr.Text = ""
    txtqtyh.Text = ""
    txtuprice.Text = ""
End Sub

Private Sub cmdSave_Click()
    Dim itemcode As String * 10
    Dim descr As String * 10
    Dim umsr As String * 10
    Dim qtyh As Integer
    Dim uprice As Currency
    Dim umsr1 As String
    Dim umsr2 As String
    Dim umsr3 As String
    Dim umsr4 As String
    itemnum = FreeFile()
    Open "C:\Users\wendell\Documents\visual basic Forms\item.txt" For Append As #itemnum
             Write #itemnum, itemcode, descr, umsr, qtyh, uprice
            
        umsr1 = "pcs"
        umsr2 = "box"
        umsr3 = "gal"
        umsr4 = "pad"
            
            'first trapping
        
        If (Len(Trim(txtcode.Text)) = 0) Or (Len(Trim(txtdescr.Text)) = 0) Or (Len(Trim(txtumsr.Text)) = 0) Or (Len(Trim(txtqtyh.Text)) = 0) Or (Len(Trim(txtuprice.Text)) = 0) Then
            MsgBox ("Fill up all the requirments before saving the file...!!")
            Exit Sub
        End If
        
            'trapping for item code
            
                 If Trim(txtcode.Text) > "A" Then
                       If Len(Trim(txtcode.Text)) <= 5 Then
                          itemcode = Trim(txtcode.Text)
                            Else
                                 MsgBox ("Inputs for item code must be not more than 5 characters..!!")
                      End If
                 Else
                       MsgBox ("First inputs for item code must be a letter..!!")
                        txtcode.SetFocus
                 End If
                  
                 
                  
                
                    'trapping for description
                            
                            If Len(txtdescr.Text) <= 40 Then
                                descr = Trim(txtdescr.Text)
                                    Else
                                     MsgBox ("Description must not be more than 40 characters..!!")
                                     txtdescr.SetFocus
                            End If
                             
                            
                    'trapping for unit of meaaure
                    
                        If Len(txtumsr.Text) <= 6 Then
                                umsr = Trim(txtumsr.Text)
                                Else
                                     MsgBox ("Unit of measure must not be more than 6 character..!!!")
                                     txtumsr.SetFocus
                        End If
                        
                            
                        
                        If (txtumsr.Text = umsr1) Or (txtumsr.Text = umsr2) Or (txtumsr.Text = umsr3) Or (txtumsr.Text = umsr4) Then
                                If Trim(txtumsr.Text) = umsr1 Then
                                        umsr = umsr1
                                        Else
                                            If Trim(txtumsr.Text) = umsr2 Then
                                                umsr = umsr2
                                                Else
                                                    If Trim(txtumsr.Text) = umsr3 Then
                                                        umsr = umsr3
                                                        Else
                                                            If Trim(txtumsr.Text) = umsr4 Then
                                                                umsr = umsr4
                                End If
                                            End If
                                                        End If
                                                                End If
                        Else
                            MsgBox ("Measure not found")
                        End If
                        
                        
                        
                                            
                    ' trapping for quantity on hand
                    
                            If IsNumeric(txtqtyh.Text) Then
                                txtqtyh.Text = txtqtyh.Text
                                    Else
                                        MsgBox ("Quantity of hand only accept integer")
                            End If
                            
                                If (Trim(txtqtyh.Text) Like "*[!0-9]*") Then
                                        MsgBox ("Quantity on hand don't accept decimal")
                                     
                            End If
                                
                                    Exit Sub
                 
                    'trapping for unit of price
                        If IsNumeric(txtuprice.Text) Then
                                txtuprice.Text = txtuprice.Text
                                    Else
                                        MsgBox ("Unit of price only accept numbers..!!")
                        End If
                     
    
                
                Close #itemnum
    
   
End Sub
  'this my form 1
Private Sub cmdDisplay_Click()
     
    
    Dim itemcode As String * 10
    Dim descr As String * 10
    Dim umsr As String * 10
    Dim qtyh As Integer
    Dim uprice As Currency
    Dim umsr1 As String
    Dim umsr2 As String
    Dim umsr3 As String
    Dim umsr4 As String
    itemnum = FreeFile()
                
                
                grd.Cols = 5
                grd.Rows = 2
                 
                 
                
                
                
                grd.TextMatrix(0, 0) = "Item Code"
                grd.TextMatrix(0, 1) = "Description"
                grd.TextMatrix(0, 2) = "UMSR"
                grd.TextMatrix(0, 3) = "Price"
                grd.TextMatrix(0, 4) = "QTYH"
                
            
             
            Open "C:\Users\wendell\Documents\visual basic Forms\item.txt" For Input As #itemnum
                
                 
                 
                Do Until EOF(itemnum)
                                  
                        
                     Input #itemnum, itemcode, descr, umsr, qtyh, uprice
                    
                        
                            grd.TextMatrix(grd.Rows - 1, 0) = itemcode
                            grd.TextMatrix(grd.Rows - 1, 1) = descr
                            grd.TextMatrix(grd.Rows - 1, 2) = umsr
                            grd.TextMatrix(grd.Rows - 1, 3) = qtyh
                            grd.TextMatrix(grd.Rows - 1, 4) = uprice
                            
                            grd.Rows = grd.Rows + 1
                    Loop
                    Close #itemnum
                            
                            
                   'this my form2         
End Sub

can someone help me figure this out..what wrong of my program is doesn't display all in the flexgrid..is there something wrong with my write and input code..

Wow, where to start.

1. In the first set of code, you open your file for append (line 21) before you do your edits. Bad idea. Finish the edits first, then write your output when all is well. Like around line 118.
2. Every edit should have an "exit sub" after its message box and setfocus, so you don't continue forward after setting focus to the offending text box.
3. You have a stray "exit sub" on line 109. This ensures that your file never gets closed. Ever.
4. Your variables on lines 11, 12 and 13 are inappropriately sized. This will cause your output data to be truncated (especially the description field).
5. Just a personal opinion, but your formatting is atrocious. It makes it very difficult to read your code.
6. There is nothing wrong with the second set of code, although the formatting could be better.

Hope this helps. Good luck!

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.