Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning SharePoint 2010 Development
This is the forum to discuss the Wrox book Beginning SharePoint 2010 Development by Steve Fox; ISBN: 978-0-470-58463-7
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning SharePoint 2010 Development section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 8th, 2010, 01:10 PM
Registered User
 
Join Date: Jul 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default MyFirstWebPart in VB

Just got this book and I am really enjoying it. However, I do most of my programming in VB while all the examples so far are in C#. It's not too hard to convert the code examples in VB, but I had a bit of a problem getting myFirstWebPart to run. However, it's working fine now, so I thought I'd add my VB version here just in case anyone else has trouble

Code:
Imports System
Imports System.ComponentModel
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.WebControls

<ToolboxItemAttribute(false)> _
Public Class MyFirstWebPart
    Inherits WebPart

    Dim lblUserEntry As Label = New Label
    Dim txtbxUserEntry As TextBox = New TextBox
    Dim lblFinalCost As Label = New Label
    Dim txtbxFinalCost As TextBox = New TextBox
    Dim btnCalcTax As Button = New Button
    Dim totalTax As Double = 0.0
    Dim prodTax As Double = 0.11


    Protected Overrides Sub CreateChildControls()

        lblUserEntry.Text = "Cost of Widget:"
        lblFinalCost.Text = "Final Cost:    "
        btnCalcTax.Text = "Calc."
        txtbxUserEntry.Text = "59.30"

        Me.Controls.Add(lblUserEntry)
        Me.Controls.Add(txtbxUserEntry)
        Me.Controls.Add(New LiteralControl("<p>"))
        Me.Controls.Add(lblFinalCost)
        Me.Controls.Add(txtbxFinalCost)
        Me.Controls.Add(New LiteralControl("<p>"))
        Me.Controls.Add(btnCalcTax)

        'From c#: btnCalcTax.Click += new EventHandler(btnCalcTax_Click)
        AddHandler btnCalcTax.Click, AddressOf btnCalcTax_Click

        'From c#: Base.CreateChildControls()
        MyBase.CreateChildControls()

    End Sub

    Private Sub btnCalcTax_Click(ByVal sender As Object, ByVal e As EventArgs)

        Dim prodCost As Double = Convert.ToDouble(txtbxUserEntry.Text)
        totalTax = Math.Round(prodCost - (prodCost * prodTax), 2) * 100 / 100
        txtbxFinalCost.Text = totalTax.ToString

    End Sub
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running a VB 2005 exe file on a system without VB dilionyi Pro Visual Basic 2005 3 September 21st, 2009 07:37 PM
VB.NET 2003 Appendix B convert to VB 2008 Express Edition brucechess BOOK: Beginning VB.NET Databases 10 February 5th, 2009 12:52 PM
Crystal Reports 11 from VB to VB.net koushik_b2002 Crystal Reports 2 June 1st, 2008 01:58 AM
convert dsr file from vb to vb.net Shashi001 VB Components 1 September 22nd, 2006 12:24 PM
VB.Net/VB/Access97/Access2002 Comparison doveb VB.NET 4 October 10th, 2003 09:54 AM



All times are GMT -4. The time now is 06:20 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.