I can't get this... :(
I can't get this... :(
I can't get this... :(
I can't get this... :(
I can't get this... :(
I can't get this... :( I can't get this... :( I can't get this... :( I can't get this... :( I can't get this... :( I can't get this... :( I can't get this... :( I can't get this... :(
I can't get this... :( I can't get this... :(
I can't get this... :(
Go Back  Xtreme Visual Basic Talk > > > I can't get this... :(


Reply
 
Thread Tools Display Modes
  #1  
Old 12-18-2003, 08:32 PM
KellyB KellyB is offline
Newcomer
 
Join Date: Dec 2003
Posts: 3
Unhappy I can't get this... :(


Hi,

Im having trouble getting this to work. I have a problem in my VB book that reads:

1) Write the code that will take the value in decTot and put it into lblTot with two digits to the right of the decimal point.

Hint: FormatCurrency

2) Write the code that will take the value in decCarTax and put it into lblCarTax with three digits to the right of the decimal point.

Hint: FormatPercent function

3) Write the code that will take the value in dblInsert and put it into lblInsert with three digits to the right of the decimal point.

Hint: FormatNumber function


Please help me get this done. My instructor says we can use any source to get the answer. She is a member of this site as well(I think).

Thanks.
Ps: that is in .net, not VB6. I didnt know where to post this, sorry.
-Kelly
Reply With Quote
  #2  
Old 12-18-2003, 08:37 PM
PlenoJure's Avatar
PlenoJureI can't get this... :( PlenoJure is offline
'With Full Right'

Retired Moderator
* Guru *
 
Join Date: Jun 2003
Posts: 1,880
Default

Did you look those function up in the MSDN and look at the examples at all? We'll help with specific questions but we wont do your homework for you.
__________________
Adam
-- Please use [vb][/vb] tags for code | Posting Guidelines | Please check the MSDN and Search before posting
-- Other Sites: Did you search Google first? | My Blog
Reply With Quote
  #3  
Old 12-18-2003, 08:47 PM
KellyB KellyB is offline
Newcomer
 
Join Date: Dec 2003
Posts: 3
Default

Quote:
Originally Posted by PlenoJure
Did you look those function up in the MSDN and look at the examples at all? We'll help with specific questions but we wont do your homework for you.




Hi,

thanks for the reply. I totally understand. I stumbled across MSDN and it helped for other problems(FormatDateTime function) but not these three. That's why im here asking for guidance. Please point me to the link or get me started on one of the questions at least. It's not homework either. It's a study guide but it is highly recommended we get it done to prepare for the final. Thank you!
Reply With Quote
  #4  
Old 12-18-2003, 08:54 PM
PlenoJure's Avatar
PlenoJureI can't get this... :( PlenoJure is offline
'With Full Right'

Retired Moderator
* Guru *
 
Join Date: Jun 2003
Posts: 1,880
Default

The MSDN included with VB.Net has examples on all of these..

Examples from the MSDN:
FormatCurrency
Code:
Dim myDebt As Double = -4456.43 Dim myString As String ' Returns"($4,456.43)". MyString = FormatCurrency(myDebt,,, TriState.True, TriState.True)
FormatPercent
Code:
Dim myNumber As Single = 0.76 Dim myString As String ' Returns "76.00%". myString = FormatPercent(myNumber)
FormatNumber
Code:
Dim myNumber As Integer = 45600 Dim myString As String ' Returns "45,600.00". myString = FormatNumber(myNumber, 2, , ,TriState.True)
__________________
Adam
-- Please use [vb][/vb] tags for code | Posting Guidelines | Please check the MSDN and Search before posting
-- Other Sites: Did you search Google first? | My Blog
Reply With Quote
  #5  
Old 12-18-2003, 09:34 PM
reboot's Avatar
rebootI can't get this... :( reboot is offline
Keeper of foo

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Graceland
Posts: 15,614
Default

Well... since those were given in the hints I suppose you should use them. But they are all from the Microsoft.VisualBasic compatibility layer, and not the preferred way to format in .Net.

If you want to impress the teacher:

Code:
Dim decTot As Double = 3764 lblTot.Text = decTot.ToString("c2") 'lblTot shows $3,764.00
Code:
Dim decCarTax As Double = .364 lblCarTax.Text = decCarTax.ToString("p3") 'lblCarTax shows 36.400 %
Code:
Dim dblInsert As Double = 456.7833 lblInsert.Text = dblInsert.ToString("n3") 'lblInsert shows 456.783
__________________
~ Quod non mortiferum, fortiorem me facit ~

Avatar by lebb
Reply With Quote
  #6  
Old 12-18-2003, 10:15 PM
KellyB KellyB is offline
Newcomer
 
Join Date: Dec 2003
Posts: 3
Default

Quote:
Originally Posted by reboot
Well... since those were given in the hints I suppose you should use them. But they are all from the Microsoft.VisualBasic compatibility layer, and not the preferred way to format in .Net.

If you want to impress the teacher:

Code:
Dim decTot As Double = 3764 lblTot.Text = decTot.ToString("c2") 'lblTot shows $3,764.00
Code:
Dim decCarTax As Double = .364 lblCarTax.Text = decCarTax.ToString("p3") 'lblCarTax shows 36.400 %
Code:
Dim dblInsert As Double = 456.7833 lblInsert.Text = dblInsert.ToString("n3") 'lblInsert shows 456.783




Hi,

Thanks for all that. I'll keep it for reference. My teacher won't see what I put for my answers because it's strictly for us. I just did like 6 different problems that were similar. Once I get an example, it's really easy.

What do you make of this:

Write the Visual Basic code that will get data from the given text box and put it into the given variable, but this time, check for invalid data by using Try/Catch statements with the methods. If the data is invalid, display a message indicating such and set focus back to the text box.

Text box: txtPress
Variable: dblPress
Reply With Quote
  #7  
Old 12-22-2003, 10:42 PM
Mike Rosenblum's Avatar
Mike Rosenblum Mike Rosenblum is offline
Microsoft Excel MVP

Forum Leader
* Guru *
 
Join Date: Jul 2003
Location: New York, NY, USA
Posts: 7,848
Default

You could do something like this:

Create a Form, then add a TextBox and change its .Name Property to "txtPress". Then add a Button and change its .Name to "btnValidate".

Then observe the following code:
Code:
' Dim dblPress As Double Private Sub btnValidate_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) _ Handles btnValidate.Click Try dblPress = CType(txtPress.Text, Double) MessageBox.Show("It's Valid! :-)") Catch MessageBox.Show("Data was NOT valid, sorry. :-(") txtPress.Select() txtPress.Select(0, txtPress.Text.Length) End Try End Sub
Hope this helps...

-- Mike
__________________
My Articles:
| Excel from .NET | Excel RibbonX using VBA | Excel from VB6 | CVErr in .NET | MVP |
Avatar by Lebb
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
I can't get this... :(
I can't get this... :(
I can't get this... :( I can't get this... :(
I can't get this... :(
I can't get this... :(
I can't get this... :( I can't get this... :( I can't get this... :( I can't get this... :( I can't get this... :( I can't get this... :( I can't get this... :(
I can't get this... :(
I can't get this... :(
 
I can't get this... :(
I can't get this... :(
 
-->