Bug with ComboBox

Post Reply
enonod
Posts: 63
Joined: Tue Nov 08, 2016 1:54 pm

Bug with ComboBox

Post by enonod »

I have made a dialog as per your example using ListBox, ComboBox.
I also tested with ListBox and DropListBox.

They all return the correct selection EXCEPT the ComboBox which ALWAYS returns the first item in the list.
Code for pasting into Editor below. Please select anything but the first item and press OK.

Code: Select all

Option Explicit

Dim pm as Object
	Set pm = CreateObject("PlanMaker.Application")
	pm.Visible = True
	pm.Activate

Dim AList$(3)
	AList(0) = "Cat"
	AList(1) = "Dog"
	AList(2) = "Elephant"

Dim BList$(3)
	BList(0) = "Sun"
	BList(1) = "Rain"
	BList(2) = "Snow"


Begin Dialog EnterData 1000, 400, 155, 100, "Enter Data"
	CancelButton 5, 85, 40, 10
	OKButton 50, 85, 40, 10
	ListBox 5, 5, 40, 80, AList$(), .ListBox1
	ComboBox 95, 5, 55, 80, BList$(), .CmboBox1
	TextBox 50, 5, 40, 10, .TxtBox1
	Text 57, 17, 40, 10, "£ Amount"
	TextBox 50, 40, 40, 10, .TxtBox2
	Button 55,55, 10, 10, "-"
	Button 75, 55, 10, 10, "+"
End Dialog

Dim dlg As EnterData, btn%

btn = Dialog (dlg)

If btn = -1 Then
	MsgBox "Chosen:  "  & AList(dlg.ListBox1) & " - " & BList(dlg.CmboBox1)
End If
Valeri Vlassov
SoftMaker Team
SoftMaker Team
Posts: 3
Joined: Mon Dec 30, 2019 4:01 pm

Re: Bug with ComboBox

Post by Valeri Vlassov »

Please use Function Dialogfn for this (changes are marked as ###) :

Option Explicit

Dim pm as Object
Set pm = CreateObject("PlanMaker.Application")
pm.Visible = True
pm.Activate

Dim AList$(3)
AList(0) = "Cat"
AList(1) = "Dog"
AList(2) = "Elephant"

Dim BList$(3)
BList(0) = "Sun"
BList(1) = "Rain"
BList(2) = "Snow"

Dim positionInBList '### added

Begin Dialog EnterData 1000, 400, 155, 100, "Enter Data", .Dialogfn
CancelButton 5, 85, 40, 10
OKButton 50, 85, 40, 10
ListBox 5, 5, 40, 80, AList$(), .ListBox1
ComboBox 95, 5, 45, 80, BList$(), .CmboBox1
TextBox 50, 5, 40, 10, .TxtBox1
Text 57, 17, 40, 10, "¥s Amount"
TextBox 50, 40, 40, 10, .TxtBox2
Button 55,55, 10, 10, "-"
Button 75, 55, 10, 10, "+"
End Dialog

Dim dlg As EnterData, btn%

btn = Dialog (dlg)

If btn = -1 Then
' MsgBox "Chosen: " & AList(dlg.ListBox1) & " - " & BList(dlg.CmboBox1) '### deleted
MsgBox "Chosen: " & AList(dlg.ListBox1) & " - " & BList(positionInBList) '### changed
End If

'####### added
Function Dialogfn(ControlID$, Action%, SuppValue%)
If ControlID$ = "CmboBox1" Then
positionInBList = SuppValue%
End if
End Function
enonod
Posts: 63
Joined: Tue Nov 08, 2016 1:54 pm

Re: Bug with ComboBox

Post by enonod »

Thank you Valeri for your assistance. I apologise for the delay but I have been indisposed.
Post Reply

Return to “BasicMaker 2018 for Windows”