Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

Assign value (numeric) to combox's items?

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-14-2007, 07:08 AM
Junior Member
 
Join Date: Aug 2007
Location: México.
Posts: 36
Unhappy Assign value (numeric) to combox's items?

Hi! I´m Newbie to Basic4ppc (Excelent tool).

My intention is to create a ComboBox that it contains Items (Product 1, Product 2, Product 3…) And on having selected, automatically there is assigned to him a numerical value (Cost) that appears in a Textbox.
Is it possible to do this?
Attachment sample file.
Thanks for his attention.
Attached Files
File Type: sbp Product.sbp (606 Bytes, 22 views)
Reply With Quote
  #2 (permalink)  
Old 08-14-2007, 07:25 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,734
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

There are several ways to achieve this.
One way is to save the prices in an ArrayList:
You will need to add an ArrayList from the designer.
Code:
Sub Globals
    
End Sub

Sub App_Start
    Form1.Show
    ArrayList1.Add(
10)
    ArrayList1.Add(
20)
    ArrayList1.Add(
30)
End Sub

Sub ComboBox18_SelectionChanged (Index, Value)
    TextBox1.Text = ArrayList1.Item(Index)
End Sub
Reply With Quote
  #3 (permalink)  
Old 08-14-2007, 07:32 AM
Junior Member
 
Join Date: Aug 2007
Location: México.
Posts: 36
Smile Thank you.

I will try it.
Thank you very much!
Reply With Quote
  #4 (permalink)  
Old 08-14-2007, 05:06 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

This kind of relation can be easily created using a ini file containing both product name and cost and add simultaneously ( to the same index ) the product name to a combobos and the cost to an array list...
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!
Reply With Quote
  #5 (permalink)  
Old 08-15-2007, 03:48 PM
Junior Member
 
Join Date: Aug 2007
Location: México.
Posts: 36
Thumbs up Thanks! It works, but another question...

It works, both! For now, I’m using Erel´s method.
Now I added another ComboBox (Tax) that it contains ítems ( A, B, C) whit another assigned cost (1,2,3).
Whit a button click, I calculate total cost of both items input previously.

Sub Button1_Click
Textbox3.Text=textbox1.Text+textbox2.Text
End Sub

It works perfectly, My question is: I can calculate and show automatically these result without the button?


Code:
Sub Globals
    
End Sub

Sub App_Start
    Form1.Show
    ArrayList1.Add(
10)
    ArrayList1.Add(
20)
    ArrayList1.Add(
30)
     ArrayList2.Add(
1)
    ArrayList2.Add(
2)
    ArrayList2.Add(
3)    
End Sub

Sub ComboBox18_SelectionChanged (Index, Value)
    TextBox1.Text = ArrayList1.Item(Index)
End Sub

Sub ComboBox2_SelectionChanged (Index, Value)
    TextBox2.Text = ArrayList2.Item(Index)
End Sub

Sub Button1_Click
Textbox3.Text=textbox1.Text+textbox2.Text
End Sub
Thanks for his responses.
Reply With Quote
  #6 (permalink)  
Old 08-15-2007, 03:55 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,734
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

What about this:
Code:
Sub App_Start
    Form1.Show
    ArrayList1.Add(
10)
    ArrayList1.Add(
20)
    ArrayList1.Add(
30)
     ArrayList2.Add(
1)
    ArrayList2.Add(
2)
    ArrayList2.Add(
3)    
    ComboBox18.SelectedIndex = 
0
    ComboBox2.SelectedIndex = 
0
End Sub

Sub ComboBox18_SelectionChanged (Index, Value)
    TextBox1.Text = ArrayList1.Item(Index)
     Textbox3.Text=textbox1.Text+textbox2.Text
End Sub

Sub ComboBox2_SelectionChanged (Index, Value)
    TextBox2.Text = ArrayList2.Item(Index)
    Textbox3.Text=textbox1.Text+textbox2.Text
End Sub
BTW, I recommend you to change the controls names to a more meaningful name. This will help you once your project grows.
Reply With Quote
  #7 (permalink)  
Old 08-15-2007, 05:50 PM
Junior Member
 
Join Date: Aug 2007
Location: México.
Posts: 36
Question Error: Input string was not in a correct format.

I will change the control names, thanks for recommendation.

I used the code
Quote:
Sub App_Start
Form1.Show
ArrayList1.Add(10)
ArrayList1.Add(20)
ArrayList1.Add(30)
ArrayList2.Add(1)
ArrayList2.Add(2)
ArrayList2.Add(3)
ComboBox18.SelectedIndex = 0
ComboBox2.SelectedIndex = 0
End Sub

Sub ComboBox18_SelectionChanged (Index, Value)
TextBox1.Text = ArrayList1.Item(Index)
Textbox3.Text=textbox1.Text+textbox2.Text
End Sub

Sub ComboBox2_SelectionChanged (Index, Value)
TextBox2.Text = ArrayList2.Item(Index)
Textbox3.Text=textbox1.Text+textbox2.Text
End Sub
but it indicates me an error:
"An error occurred on sub combobox18 selectionchanged.
Line number: 14

Textbox3.Text= textbox1.Text+textbox2.Text
Error description:
Input string was not in a correct format.
Continue?...

Which is the error?
Reply With Quote
  #8 (permalink)  
Old 08-15-2007, 05:58 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,734
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Add these lines to Sub App_Start (first lines):
TextBox2.Text = ""
TextBox3.Text = ""
Reply With Quote
  #9 (permalink)  
Old 08-15-2007, 07:36 PM
taximania's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Derbyshire. UK
Posts: 592
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by Cableguy View Post
This kind of relation can be easily created using a ini file containing both product name and cost and add simultaneously ( to the same index ) the product name to a combobos and the cost to an array list...

Using the binary.dll ? you could create and save, 'then modify if you wish', a file on disk .dat .ini .ect so the information or value's you want are already set in the textbox? 'values'. Read the values of the file with your App_Start Sub

This is an addition I could have made to my port settings in my 'bad' GPS example. I didn't.

Perhaps I'll try and see if it works
__________________
.
.
.
Don't ask, I'm fine, honest. !!
.
.
.
Just a little crazy at times



O2 XDA, GW Evo 2.1 UC WWE Rom, WM6.1
Radio Ver 03.34.90
With Basic4ppc V6.80


http://www.taximania.co.uk
Reply With Quote
  #10 (permalink)  
Old 08-15-2007, 07:40 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

I was not targeting the binary dll in my answer, only how to create and matain a valid relation beetween the combobox and the textboxes values...

Sorry but I just don't see were binary dll was mentioned in this thread...
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!

Last edited by Cableguy : 08-15-2007 at 07:43 PM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Leading zero(s) for numeric or string type variable not saved in database. mozaharul Questions (Windows Mobile) 1 10-26-2008 04:18 PM
Assign icons to forms? BjornF Questions (Windows Mobile) 12 02-26-2008 08:20 AM
Numeric Data Mask - Using Regular Expressions david Questions (Windows Mobile) 2 01-04-2008 01:13 PM
Numeric Data Input Mask? david Questions (Windows Mobile) 3 11-03-2007 03:04 PM
Numeric conversion limitation? agraham Bug Reports 5 07-06-2007 05:08 PM


All times are GMT. The time now is 10:59 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0