Beginner VB

Moderators: None (Apply to moderate this forum)
Number of threads: 1244
Number of posts: 2990

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
ComboBox and calculations Posted by satsoc on 6 Apr 2002 at 8:32 AM
hi guys,
i was wondering if we could create a program with a ComboBox that includes km,m,cm and if we choose km for example it converts them to mm.

Any ideas how it can be done?(1km = 1000m,etc...)

Report
Re: ComboBox and calculations Posted by KDivad Leahcim on 6 Apr 2002 at 7:07 PM
: hi guys,
: i was wondering if we could create a program with a ComboBox that includes km,m,cm and if we choose km for example it converts them to mm.
:
: Any ideas how it can be done?(1km = 1000m,etc...)

Easy, as long as you know the calculations:
Combo1.AddItem "km -> mm (1:1000)"
Combo1.AddItem "mm -> km (1000:1)"

Private Sub Combo1_Click()

    Select Case Combo1.ListIndex
    Case 0
        Text2.Text = CStr(Val(Text1.text) * 1000)
    Case 1
        Text2.Text = CStr(Val(Text1.text) / 1000)
    End Select

End Sub

Hope this helps!



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.