 |
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

December 20th, 2010, 03:57 PM
|
|
Registered User
|
|
Join Date: Dec 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

December 24th, 2010, 07:24 AM
|
|
Authorized User
|
|
Join Date: May 2010
Posts: 70
Thanks: 4
Thanked 6 Times in 6 Posts
|
|
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..
|
|

March 4th, 2011, 07:09 PM
|
|
Authorized User
|
|
Join Date: Dec 2007
Posts: 26
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
|

March 14th, 2011, 07:21 AM
|
|
Authorized User
|
|
Join Date: May 2010
Posts: 70
Thanks: 4
Thanked 6 Times in 6 Posts
|
|
Displaying Last half of String
Quote:
Originally Posted by gfranco
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.
|
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 |
|
 |
|