Professional Documents
Culture Documents
HTTP WWW - Dummies
HTTP WWW - Dummies
PowerBasic vs VisualBasic Faster. No Run-Times. No Bloat! CGI, Macros, ASM, Reg Expressions www.powerbasic.com
Lipid Analytical Services MS/MS, NMR, Reference Standards Stability Testing, Method Dev. www.avantilipids.com
Java Persistence Tools OpenJPA, Toplink, Hibernate Suppt No Lock-in, Eclipse-Based www.myeclipseide.com
• Int returns the first negative integer that's less than or equal to the argument.
• Fix returns the first negative integer that's greater than or equal to the argument.
Determining a file size
The following Sub procedure displays the size, in bytes, of the Excel executable file. It finds this value by
using the FileLen function.
Sub GetFileSize()
Dim TheFile As String
TheFile = "c:\MSOFFICE\EXCEL\EXCEL.EXE"
MsgBox FileLen(TheFile)
End Sub
Notice that this routine hard codes the filename (that is, it explicitly states the path). Generally, this isn't a
good idea. The file might not be on the C drive, or the Excel folder may have a different name. The
following statement shows a better approach:
TheFile = Application.Path & "\EXCEL.EXE"
Path is a property of the Application object. It simply returns the name of the folder in which the
application (that is, Excel) is installed (without a trailing backslash).
Identifying the type of a selected object
The following procedure uses the TypeName function, which returns the type of the selected object (as a
string):
Sub ShowSelectionType()
Dim SelType As String
SelType = TypeName(Selection)
MsgBox SelType
End Sub
This could be a Range, a ChartObject, a TextBox, or any other type of object that can be selected.
The TypeName function is very versatile. You can also use this function to determine the data type of a
variable.
MsgBox Displays a handy dialog box containing a message and buttons. The function returns a
code that identifies which button the user clicks.
InputBox Displays a simple dialog box that asks the user for some input. The function returns
whatever the user enters into the dialog box.
Shell Executes another program. The function returns the task ID (a unique identifier) of the
other program (or an error if the function can't start the other program).
DateDiff Returns an integer showing the number of specified time intervals between two dates,
for example the number of months between now and your birthday
Exp Returns the base of the natural logarithm (e) raised to a power
TimeSerial Returns the time for a specified hour, minute, and second
Related
Login
Add New Comment
Showing 18 comments
Watto
Lindacross2010 If you are using ecel and want the format of the column to be 4 digits you can go to format cell and
choose custom, type 0000 as the format and all numbers in that cell will be 4 digits. ie 20 would be displayed as
0020.
Lindaross2010
Hello, I need help. I have a column of numbers, some are 3 digit numbers and some are 4. I need to add a 0 to the
3 digit numbers. I need Excel vba code to do this. Thanks
donna adams
ingeseecrarne
James
Mike
Mike
Hi, does anyone know how to make the VBA code repeat itself? For
example: I recorded a macro that uses the solver (in excel) and I
would like to apply the macro on multiple optimization problems
with the same constraints over and over again. The macro I recorded
will only apply the solver on those cells specified in the code.
Thanks
Brian
i need to create a formula that will add 365 cells located every
other row apart.
Alain
Please can anyone inform me about how can I find anything related
to VBA in ArcGIS, such as tutorial or code?? Thank you. Regards
husna
husna
Claes
David Harriman
I have a calendar which consists of 365 rows plus twelve for the
months. One column contains the dates and the adjacent column the
days. I use this to enter birthdays, anniversaries, appointments,
meetings, games, etc. I enter this info in the next two or three
columns in the day and date row. I have a cell with the week number
WN in it, and wanted a macro that would look at WN and go to the
week that corresponds with it. I've done this for twenty years
easily in Lotus or Quatropro, with a list of IFs and GoTos. I can't
do it in VB. Got any ideas?
uma
4ndyman
Cassie,
You can't format the string itself, but you can format it after
you place it. For example:
Title = "CO2"
ActiveCell.Value = Title
ActiveCell.Characters(3,1).Font.Subscript = True
If you need to use CO2 a lot, and in different places each time
you use it, you could use the InStr method to find which character
needs to be subscript. In this case,
...
With Sheets(myMonth).Range("A1")
.Value = myTitle
.Characters(InStr(myTitle,"CO2") +
2,1).Font.Subscript=True
End With
In this case, the InStr function will return the position of the
"C", so you need to add 2 to it to get to the 2 that you want to
subscript.
DC
Ron - you can do that by coding an input box where you want the
code to pause and ask for input. This may not be the "correct" way,
but one option is: activecell.value = InputBox("Enter Data")
Cassie
Like
Copyright © 2012 & Trademark by John Wiley & Sons, Inc. All rights reserved.