I want to reload my form in Vb6 without closing it. I am sending a data through serial comm and receiving it. Now i want the repeat the procedure again without closing the Form. The problem is , I don't want to unload the form.It should get reloaded automatically

Recommended Answers

All 7 Replies

Hi

You shouldn't have to reload the form to receive data unless you have your code that receives data in the Load event of the form. If that is the case, I would recommend moving the code out to its own procedure and then maybe use a timer to repeatedly call that procedure at a suitable interval.

HTH

can you please paste your code?

Private Sub Form_Load()
With serie

   If .PortOpen Then .PortOpen = False

   .CommPort = 4
   .Settings = "9600,N,8,1"
   .DTREnable = True
   .RTSEnable = True
   .RThreshold = 1
   .SThreshold = 0
   .PortOpen = True
   End With

Private Sub serie_OnComm()
   Text2.Text = serie.Input ' Taking input in textbox
   MsgBox "f"   'printing f
   Unload Form1  'unloading form1
   Form1.Show    'reloading Form1
End Sub

The problem is i dont want to unload the form and load again. I want the form to get loaded automatically after i print "f". So that again i can do the process again ,but without unloading it

I have no experience with the code that you have posted, but I am assuming (maybe wrongly) that the serie_OnComm is fired each time you receive data? Is that correct? If so, why do you need to unload and reload the form?

No it doesn't.We need to load the form again to start the process again.

You seem to be missing an End Sub in the code above for the Form_Load() event.

No it doesn't.We need to load the form again to start the process again.

So, how does serie_OnComm get called? I don't see this in your code. Also, why don't you put the setup of your serie object into its own procedure that you can call from Form_Load():

Private Sub SetupSerie()

    With serie

       If .PortOpen Then .PortOpen = False

       .CommPort = 4
       .Settings = "9600,N,8,1"
       .DTREnable = True
       .RTSEnable = True
       .RThreshold = 1
       .SThreshold = 0
       .PortOpen = True

    End With

End Sub

Private Sub Form_Load()

    SetupSerie()

End Sub

Private Sub serie_OnComm()

    Text2.Text = serie.Input
    MsgBox "f"

End Sub

Then you could also have a timer that calles SetupSerie() if that is what needs to happen in order to get input. This way you do not need to reload the form.

Yeah it worked.i did it using Timer.Thanks.

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.