Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning Microsoft Visual Basic 2010
This is the forum to discuss the Wrox book Beginning Visual Basic 2010 by Thearon Willis, Bryan Newsome; ISBN: 9780470502228
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Microsoft Visual Basic 2010 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 December 20th, 2010, 03:57 PM
Registered User
 
Join Date: Dec 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 3 Exercise 2

Create a Windows application with a text box and a button control. In the button’s Click event,
display three message boxes. The first message box should display the length of the string that
was entered into the text box. The second message box should display the first half of the string,
and the third message box should display the last half of the string.


please solve it
Reply With Quote
  #2 (permalink)  
Old December 24th, 2010, 07:24 AM
Authorized User
Points: 319, Level: 6
Points: 319, Level: 6 Points: 319, Level: 6 Points: 319, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2010
Location: MIssouri
Posts: 70
Thanks: 4
Thanked 6 Times in 6 Posts
Send a message via Yahoo to GeneBuchite
Default MsgBox

Something Like this should work
Code:
 
If Len(Textbox1.Text) < 1 Then TextBox1.Text = "Default Text"
       Dim x As Integer = Len(TextBox1.Text)
        Dim h As Integer = x / 2

        MsgBox(x)
        MsgBox(Strings.Left(TextBox1.Text, h))
        MsgBox(Strings.Right(TextBox1.Text, h))
Just Copy & Paste into the Button1_Click Event..
Reply With Quote
  #3 (permalink)  
Old March 4th, 2011, 07:09 PM
Authorized User
Points: 185, Level: 3
Points: 185, Level: 3 Points: 185, Level: 3 Points: 185, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2007
Location: , , .
Posts: 26
Thanks: 0
Thanked 1 Time in 1 Post
Default Chapter 3 final exercise 3 buttons

Display 3 messages
1. Lenght of string
2. Halft of string
3. Last half of string (no clue)

I have done both, how can I accomplish the 3 one?

PrivateSub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim strResult AsString
strResult = TextBox1.Text
MessageBox.Show("showing Lenght of string " & strResult.Length, "String")
MessageBox.Show("showing first half of string " & strResult.Substring(0, CType(strResult.Length / 2, Integer)), "Strings")
'MessageBox.Show("showing last half of sting" & strResult.Length, "String")
EndSub
Reply With Quote
  #4 (permalink)  
Old March 14th, 2011, 07:21 AM
Authorized User
Points: 319, Level: 6
Points: 319, Level: 6 Points: 319, Level: 6 Points: 319, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2010
Location: MIssouri
Posts: 70
Thanks: 4
Thanked 6 Times in 6 Posts
Send a message via Yahoo to GeneBuchite
Default Displaying Last half of String

Quote:
Originally Posted by gfranco View Post
Display 3 messages
1. Lenght of string
2. Halft of string
3. Last half of string (no clue)

I have done both, how can I accomplish the 3 one?

PrivateSub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim strResult AsString
strResult = TextBox1.Text
MessageBox.Show("showing Lenght of string " & strResult.Length, "String")
MessageBox.Show("showing first half of string " & strResult.Substring(0, CType(strResult.Length / 2, Integer)), "Strings")
'MessageBox.Show("showing last half of sting" & strResult.Length, "String")
EndSub
Just index your start index to half of the length of the string. Ie..
Code:
 MessageBox.Show("showing first half of string " & strResult.Substring(strResult.Length / 2, CType(strResult.Length / 2, Integer)), "Strings")
Sorry to take so long to reply, I had to research this for a while. Was good for me though. Good Luck. Dont hesitate to re-post for more help.
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
Exercise 6 for chapter 2 scooter5 BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 3 August 27th, 2010 11:24 AM
Chapter 8 exercise 3 Will BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 8 March 4th, 2010 04:15 AM
Chapter 4 Exercise 4 Will BOOK: Beginning Microsoft Visual C# 2008 ISBN: 978-0-470-19135-4 2 September 18th, 2009 11:08 AM
Chapter 3 - Exercise 3 AndyN BOOK: Beginning Cryptography with Java 3 August 16th, 2006 03:09 PM
Chapter 4, Exercise 3 DRAYKKO BOOK: Beginning Java 2 3 July 9th, 2004 02:34 PM



All times are GMT -4. The time now is 05:50 AM.


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