Autor Tema: como leer los option button en archivo secuencial  (Leído 535 veces)

0 Usuarios y 1 Visitante están viendo este tema.

plotor

  • Bytes
  • *
  • Mensajes: 19
  • Reputación: +0/-0
    • Ver Perfil
como leer los option button en archivo secuencial
« en: Mayo 15, 2024, 07:35:07 pm »
Hola
estoy haciendo un pequeño proyecto en visual basic 6.0

cuando guarda los datos me los guarda bien

el problema que tengo del proyecto es que no me lee los options buttons los demas valores si los lee

hay dos frame

 ------------------------                         ----------------------------
    0 option1     label7                              0 option2        label9
    0 option1     label8                              0 option2        label10
-------------------------                        ------------------------------

           text6.text                                         text7.text


aqui dejo el codigo



Código: [Seleccionar]

Public Sub limpiar()
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Text5 = ""
Text1.SetFocus
End Sub



Private Sub Command1_Click()
Dim mat As String * 7
Dim nom As String * 30
Dim postnom As String * 30
Dim sexe As String * 10
Dim price As String * 10
Dim datenaiss As String * 10
Dim adresse As String * 40
mat = Text1
nom = Text2
postnom = Text3

datenaiss = Text4

adresse = Text5

sexe = Text6.Text

price = Text7.Text

Open App.Path & "\fichero estudiante\" & (nom + ".txt") For Output As #1
Write #1, mat, nom, postnom, Option1(0).Value, Option1(1).Value, sexe, Option2(0).Value, Option2(1).Value, price, datenaiss, adresse
Close #1
MsgBox "Guardado exitosamente !", vbInformation, "Gestion Estudiante"
limpiar
End Sub

Private Sub Command2_Click()
limpiar
End Sub



Private Sub Command4_Click()
End
End Sub



Private Sub Command5_Click()

Dim F_check1, F_check2, F_check3, F_check4 As Integer


cd1.InitDir = App.Path & "\fichero estudiante\"
    cd1.ShowOpen





Open cd1.FileName For Input As #1


Do While EOF(1) <> -1
Input #1, mat, nom, postnom, F_check1, F_check2, sexe, F_check3, F_check4, price, datenaiss, adresse
Text1 = mat
 Text2 = nom
 Text3 = postnom

 Text4 = datenaiss

Text5 = adresse
If Option1(Index).Value = True Then
 
Option1(0).Caption = F_check1
Text6.Text = sexe
Else
Option1(1).Caption = F_check2
Text6.Text = sexe
End If

Text6.Text = sexe

If Option2(Index).Value = True Then
 Option2(0).Caption = F_check3
Else
Option2(1).Caption = F_check4
End If

 Text7.Text = price
Loop
Close #1



End Sub

Private Sub Option1_Click(Index As Integer)
Select Case Index
Case 0: Text6.Text = Label7.Caption
Case 1: Text6.Text = Label8.Caption
End Select
End Sub


Private Sub Option2_Click(Index As Integer)
Select Case Index
Case 0: Text7.Text = Label9.Caption
Case 1: Text7.Text = Label10.Caption
End Select
End Sub




gracias




benito

  • Bit
  • Mensajes: 3
  • Reputación: +1/-0
    • Ver Perfil
Re:como leer los option button en archivo secuencial
« Respuesta #1 en: Mayo 16, 2024, 03:43:51 pm »
cambia el evento Command5_Click por este código  :)

Código: [Seleccionar]

Private Sub Command5_Click()

Dim F_check1, F_check2, F_check3, F_check4 As Integer


cd1.InitDir = App.Path & "\fichero estudiante\"
    cd1.ShowOpen

Open cd1.Filename For Input As #1


Do While EOF(1) <> -1
   
   Input #1, mat, nom, postnom, F_check1, F_check2, sexe, F_check3, F_check4, price, datenaiss, adresse

   Text1 = mat
   Text2 = nom
   Text3 = postnom
   Text4 = datenaiss
   Text5 = adresse
   
   If CBool(F_check1) = True Then
      Option1(0).value = True
   Else
      Option1(1).value = True
   End If
   
   'If Option1(index).value = True Then
   '   Option1(0).Caption = F_check1
   '   Text6.Text = sexe
   'Else
   '   Option1(1).Caption = F_check2
   '   Text6.Text = sexe
   'End If
   
   Text6.Text = sexe

   If CBool(F_check3) = True Then
      Option2(0).value = True
   Else
      Option2(1).value = True
   End If
   
   'If Option2(index).value = True Then
   '   Option2(0).Caption = F_check3
   'Else
   '   Option2(1).Caption = F_check4
   'End If

   Text7.Text = price

Loop

Close #1

End Sub

plotor

  • Bytes
  • *
  • Mensajes: 19
  • Reputación: +0/-0
    • Ver Perfil
Re:como leer los option button en archivo secuencial
« Respuesta #2 en: Mayo 16, 2024, 04:58:46 pm »
muchas gracias Benito

justo lo que necestiava

solo una cosa


en el primer frame hubiesen cuatro option button y en el segundo 2 option button como seria el procedimiento de leer
gracias

plotor

  • Bytes
  • *
  • Mensajes: 19
  • Reputación: +0/-0
    • Ver Perfil
Re:como leer los option button en archivo secuencial
« Respuesta #3 en: Mayo 17, 2024, 06:58:14 am »
ya lo he solucionado

solucion

Código: [Seleccionar]

Dim F_check1, F_check2, F_check3, F_check4, F_check5, F_check6 As Integer


cd1.InitDir = App.Path & "\fichero estudiante\"
    cd1.ShowOpen

Open cd1.FileName For Input As #1


Do While EOF(1) <> -1
   
   Input #1, mat, nom, postnom, F_check1, F_check2, F_check3, F_check4, sexe, F_check5, F_check6, price, datenaiss, adresse

   Text1 = mat
   Text2 = nom
   Text3 = postnom
   Text4 = datenaiss
   Text5 = adresse
   
   If CBool(F_check1) = True Then
      Option1(0).Value = True
    End If
    If CBool(F_check2) = True Then
      Option1(1).Value = True
      End If
     If CBool(F_check3) = True Then
      Option1(2).Value = True
    End If
    If CBool(F_check4) = True Then
      Option1(3).Value = True
   End If
   
   'If Option1(index).value = True Then
   '   Option1(0).Caption = F_check1
   '   Text6.Text = sexe
   'Else
   '   Option1(1).Caption = F_check2
   '   Text6.Text = sexe
   'End If
   
   Text6.Text = sexe

   If CBool(F_check5) = True Then
      Option2(0).Value = True
   Else
      Option2(1).Value = True
   End If
   
   'If Option2(index).value = True Then
   '   Option2(0).Caption = F_check3
   'Else
   '   Option2(1).Caption = F_check4
   'End If

   Text7.Text = price

Loop

Close #1







tema resuelto

muchas gracias