Re: Fruit basket program in Visual Basic 10 with Layout by Code

  • From: "qubit" <lauraeaves@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Thu, 24 Jun 2010 15:32:00 -0500

perhaps you should put it on the fruitbasket site.
--le
----- Original Message ----- 
From: "Jamal Mazrui" <empower@xxxxxxxxx>
To: <ProgrammingBlind@xxxxxxxxxxxxx>
Sent: Thursday, June 24, 2010 2:44 PM
Subject: Fruit basket program in Visual Basic 10 with Layout by Code


From the archive
http://EmpowermentZone.com/vblbc_fruit.zip

This fruit basket is written in Visual Basic 10 (which was released in 
April, 2010).  It uses the Homer.NET library, distributed with the Homer 
application framework, HomerApp, available at
http://EmpowermentZone.com/appsetup.exe

or .zip for a manual install.

Five Homer.NET assemblies, matching Homer*.dll, need to be included in the 
same directory as the executable, vblbc_fruit.exe.  The batch file, 
compile.bat, builds the executable using the Visual Basic command-line 
compiler, vbc.exe, based on the source code, vblbc_fruit.vb.

A compiler response file, Homer.rsp, sets most compiler parameters.  This 
response file can also be used to compile VB programs within the EdSharp 
editor, available at
http://EmpowermentZone.com/edsetup.exe

To do this, set the CompileCommand setting in the EdSharp Configuration 
Options dialog to the following string:

vbc.exe @Homer.rsp "%Source%" 2>&1

The commented source code is also pasted below.

Jamal

' Fruit basket in Visual Basic 10 with Layout by Code
' Public domain by Jamal Mazrui
' June 24, 2010

' Require variables to be explicitly declared
Option Explicit On
' Require type casts to be explicitly done
Option Strict On

' Import namespaces
imports Homer
imports System
imports System.ComponentModel
imports System.Windows.Forms

' Declare a class named 'Dialog' that inherits from the class named 
'LbcForm'
Class Dialog
Inherits LbcForm

' Define the main event handler for this form
public Sub OnEvent(sEvent As String, oSender As Object, oArgs As 
EventArgs)
' Get references to the TextBox and ListBox widgets of this form
Dim txt As TextBox = me.GetTextBox("Fruit")
Dim lst As ListBox = me.GetListBox("Basket")

' Declare other local variables used in this event handler routine
Dim iCount, iIndex As Integer
Dim sFruit, sWidgetName As String

' Test for an event by name
Select Case sEvent
Case "Closing"
If Lbc.DialogConfirm("Confirm", "Exit program?", "Y") <> "Y" Then 
CType(oArgs, CancelEventArgs).Cancel = True
Case "Click"
' Test for a widget by name
sWidgetName = Lbc.GetName(oSender)
Select Case sWidgetName
Case "Button_Add"
sFruit = txt.Text
If sFruit.Length = 0 Then
Lbc.DialogShow("Alert", "No fruit to add!")
Else
lst.Items.Add(sFruit)
iIndex = lst.Items.Count - 1
lst.SelectedIndex = iIndex
txt.Clear()
End If
Case "Button_Delete"
iIndex = lst.SelectedIndex
If iIndex = -1 Then
Lbc.DialogShow("Alert", "No fruit to delete!")
Else
lst.Items.RemoveAt(iIndex)
iCount = lst.Items.Count
If iCount = 0 Then Return
If iIndex = iCount Then iIndex -= 1
  lst.SelectedIndex = iIndex
End If
End Select
End Select
End Sub ' OnEvent method

' Define entry point of the program
Shared Sub Main()

' Instantiate an object of the Dialog class
Dim dlg As Dialog = New Dialog()
End Sub ' Main method

' Define the constructor of the Dialog class
Sub New()
' Set the dialog title
me.Init("Fruit Basket")

' Add a 'Fruit' label and a TextBox
me.AddInputBox("Fruit")

' Add a default button named 'Add'
me.AcceptButton = me.AddButton("Add")

' Start a new band of widgets
me.AddBand()

' Add a 'Basket' label and a ListBox
me.AddPickBox("Basket")

' Add a button named 'Delete'
me.AddButton("Delete")

' Complete setup of the dialog and activate it
me.CompleteDialog()
End Sub ' New method
End Class ' Dialog class

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: