Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / March 2005

Tip: Looking for answers? Try searching our database.

Syntax to show message

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
craignbaker@hotmail.com - 05 Mar 2005 03:41 GMT
I would like to show you the syntax for VBA I debugged successfully:

Dim strHours As String, strRate As String
Dim hours As Single, rate As Single, gross As Single

strHours = InputBox("Enter the hours")
strRate = InputBox("Enter the rate")

hours = Val(strHours)           'converts a string to a number
rate = Val(strRate)

gross = hours * rate

MsgBox ("The gross pay is " & Str(gross))  'Str(gross) converts a number to
a string

Tax = Val(25 / 100 * gross)

NetPay = Val(gross - Tax)

Dim FirstName As String
FirstName = InputBox("Enter the First Name")
MsgBox "The First Name is John"

Dim LastName As String
LastName = InputBox("Enter the Last Name")
MsgBox "The Last Name is Smith"

Dim FullName As String
FullName = InputBox("Enter the First Name" + "Enter the Last Name")
MsgBox "The Full Name is John Smith"

The following syntax that was supposed to display the MsgBox "Pay details
for John Smith are Gross = 400, Tax = 100, Net = 300" is incorrect:

Gross = "Gross = (gross)" + Tax = "Tax = (Tax)" + NetPay = "NetPay =
(NetPay)"")

Yours Sincerely
Steve Schapel - 05 Mar 2005 08:42 GMT
Craig,

Here's how I would do it...

---------------------
 Dim hours As Currency
 Dim rate As Currency
 Dim gross As Currency
 Dim Tax As Currency
 Dim NetPay As Currency
 Dim FirstName As String
 Dim LastName As String
 Dim FullName As String

 hours = InputBox("Enter the hours")
 rate = InputBox("Enter the rate")

 gross = hours * rate
 MsgBox "The gross pay is " & gross
 Tax = .25 * gross
 NetPay = .75 * gross

 FirstName = InputBox("Enter the First Name")
 MsgBox "The First Name is " & FirstName
 LastName = InputBox("Enter the Last Name")
 MsgBox "The Last Name is " & LastName
 FullName = FirstName & " " & LastName
 MsgBox "The Full Name is " & FullName

 MsgBox "Pay details for " & FullName & " are Gross = " & gross & ",
Tax = " & Tax & ", Net = " & NetPay

----------------------

Signature

Steve Schapel, Microsoft Access MVP

> I would like to show you the syntax for VBA I debugged successfully:
>
[quoted text clipped - 35 lines]
>
> Yours Sincerely
craignbaker@hotmail.com - 06 Mar 2005 03:31 GMT
I forget to mention that I want to use the "str" function.

Craig Baker

> Craig,
>
[quoted text clipped - 69 lines]
> >
> > Yours Sincerely
Steve Schapel - 06 Mar 2005 04:19 GMT
Craig,

You did use the Str() function, in your original example...  but your
original example is unnecessarily complicated.  Why do you want to use
the Str() function if there is no need to?

Signature

Steve Schapel, Microsoft Access MVP

> I forget to mention that I want to use the "str" function.
>
[quoted text clipped - 73 lines]
>>>
>>>Yours Sincerely
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.