Source code for Visual Basic Client
Dim ctx As Object
Dim broker As Object
Dim account As Object


Rem Connect to WebLogic Server
Private Sub Connect_Click()
    Set WebLogic = GetObject("java:weblogic.com.Tengah")
    Set ctx = WebLogic.getInitialContext(URL.Text)
    Set broker = ctx.lookup("beanManaged.AccountHome")
    LookupAccount.Enabled = True
    AccountNum.Enabled = True
    URL.Enabled = False
    Connect.Enabled = False
End Sub

Rem Initialize dialog
Private Sub Form_Load()
    Amount.Enabled = False
    Withdraw.Enabled = False
    Deposit.Enabled = False
    LookupAccount.Enabled = False
    AccountNum.Enabled = False
End Sub

Rem Look up the account
Private Sub LookupAccount_Click()

    On Error GoTo lookupfailed
    Set pk = GetObject("java:examples.ejb.beanManaged.interfaces.AccountPK")
    pk.accountId = AccountNum.Text
    Set account = broker.findByPrimaryKey(pk)
    GoTo success
    
lookupfailed:
    On Error GoTo createfailed
    Set account = broker.Create(AccountNum.Text, 3000)
    GoTo success
    
createfailed:
    AccountNum.Text = "assertion, shouldn't happen"
    Exit Sub
    
success:
    Balance.Caption = account.Balance
    Amount.Enabled = True
    Withdraw.Enabled = True
    Deposit.Enabled = True
    Summary.Caption = ""
End Sub

Rem Withdraw from the account
Private Sub WithDraw_Click()
    On Error GoTo withdrawfailed
    account.Withdraw Amount.Text
    Balance.Caption = account.Balance
    Summary.Caption = ("Withdrew $" + Amount.Text)
    Amount.Text = ""
    Exit Sub
    
withdrawfailed:
    Summary.Caption = "Withdraw failed, rolling back transaction"
    Amount.Text = ""
    
End Sub

Rem Deposit into the account
Private Sub Deposit_Click()
    On Error GoTo depositfailed
    account.Deposit Amount.Text
    Balance.Caption = account.Balance
    Summary.Caption = ("Deposited $" + Amount.Text)
    Amount.Text = ""
    Exit Sub
    
depositfailed:
    Summary.Caption = "Deposit failed"
    Amount.Text = ""

End Sub




Author:
Copyright (c) 1999-200- by BEA Systems, Inc. All Rights Reserved.