 |
|
 |
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
Re: Procedure too larger error??
Well, I am not sure what exactly do you do with this code, but if you want to make your procedure smaller then you can use For... Next, altought it will make reading code harder. This code will insert all AB** items in your RepName_Click procedure.
For inCnt = 10 To 56
PostCode.AddItem "AB" & inCnt
If inCnt = 16 or inCnt = 25 Then
inCnt = inCnt + 4
ElseIf inCnt = 39 Then
inCnt = inCnt + 1
ElseIf inCnt = 45 Then
inCnt = 50
End If
Next inCnt |
Next, I dont see the point in clearing combobox and adding SAME data in PostCode everytime RepName is clicked. Also the same thing with SalesType. You are adding the same data everytime when you click on RepName, while you can do it only once. As, I said, I dont quite understand what exactly are you trying to achieve, but this is surely not well organised code. Maybe you can store all this items from AB10 to PH22 to some file, so you can read it and load it to combobox with much less code.
____________________________
If you find the answer helpful, please mark this topic as solved.
|
|
24-02-2004 at 08:22 PM |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
Re: Procedure too larger error??
Search this forum, there is plenty of code about writing to a file. Also, you might want to reconsider organising your data in tables (I suggest that you already have a database), its much more easier to work with tables instead with sequential files. I will post here 2 small examples how to read and write to a sequential file, and for more info, search this forum or MSDN.
Private Sub WriteToFile()
Dim ff As Integer
ff = FreeFile
' Open the file
Open "Testfile" For Output As #ff
Write #ff, "AB10"
Write #ff, "AB11"
Write #ff, "AB12"
'..................
Close #ff
End Sub
Private Sub ReadFromFile()
Dim ff As Integer
Dim str As String
ff = FreeFile
' Open the file
Open "TestFile" For Input As #ff
Do While Not EOF(ff)
Input #ff, str
Combo1.AddItem str
Loop
Close #ff
End Sub |
First call WriteToFile procedure to create file 'TestFile' and to add data to it, and then call ReadFromFile procedure to read data from it and, as an example, I added line that will display data that you read in ComboBox control named Combo1.
____________________________
If you find the answer helpful, please mark this topic as solved.
|
|
24-02-2004 at 10:19 PM |
|
|
|
|
 |
 |