What I want to do is make the Comport No. in the code below variable so that when the Program starts I am asked which Port No. I rquire ans this is written to a variable which i can call in the main program. I have the feeling i can only do this with an additional form and a textbox and a text question, or with push buttons and predetermined port numbers. I would like to use any port number upto say 20. Can someone please answer the following questions.
Do I have to use an extra form?
If not how do I incorperate the port number entry into the existing program?
If I do need a form how do I go about this.
I do realiSubze that I need to show my existing work, and it is there but I have no idea how to start.
I have listed the code I have below.
The first code list only shows the relevent part i.e. the Commport = Comport
'Option Explicit Dim Newdata As String 'each imcoming packet is assembled here Private Sub Form_Load() Form1.Caption = "OE8PCK Digital Wattmeter" With MSComm1 .CommPort = Comport .Handshaking = 2 - comRTS .RThreshold = 1 .RTSEnable = True .Settings = "9600,n,8,1" .SThreshold = 1 .PortOpen = True ' Leave all other settings as default values. End With OutputDisplay.Text = "Infobox" + vbCr + vbLf InformationDisplay.Text = "Databox" + vbCr + vbLf Newdata = "" 'initialize to empty End
Option Explicit 'form2 = 1 Private Sub Form_Load() Form2.Caption = "OE8PCK Digital Wattmeter" Dim Comport As Integer End Sub Private Sub Option1_Click() Comport = 1 End Sub Private Sub Option2_Click() Comport = 2 End Sub Private Sub Option3_Click() Comport = 3 End Sub Private Sub Option4_Click() Comport = 4 End Sub Private Sub Option5_Click() Comport = 5 End Sub Public Sub CloseWindow() Unload Form2 Load Form1 Form1.Show End Sub
This post has been edited by oe8pck: 08 July 2009 - 07:50 AM