13:05 ET Dow -154.48 at 10309.92, Nasdaq -37.61 at 2138.44, S&P -19.130 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 13:05 ET Dow -154.48 at 10309.92, Nasdaq -37.61 at 2138.44, S&P -19.1313:05 ET Dow -154.48 at 10309.92, Nasdaq -37.61 at 2138.44, S&P -19.13

.

.

Tuesday, March 9, 2010

Transcript of Testimony of James H. Simons - Before the House Committee on Oversight and Government Reform - Nov. 13, 2008

Testimony of James H. Simons
Before the House Committee on Oversight and Government Reform
November 13,2008
Good morning Chairman Waxman, Ranking Member Davis, and members of the Committee.
My name is James Simons, and I am the Chairman and CEO of Renaissance Technologies LLC.
Thank you for the invitation to appear before you today.
I appreciate and welcome your interest in understanding the underlying causes of the recent
financial crisis. This is indeed a serious and disturbing time for the markets, the broader
economy, and our nation as a whole. Individual Americans are hurting and are fearful for their
financial futures, and businesses of all sizes are facing problems. Hedge funds are having
trouble along with everybody else. Some smaller funds have failed, and some others, both big
and small, are struggling to stay afloat. Federal agencies are trying to do their best, but this is a
very difficult situation. I am pleased to be here to answer your questions about these issues, and
I stand ready to work with you and your staffs as the situation unfolds in the months ahead.
Before turning to the specific questions raised by your letter inviting me to testiff, I would like to
provide you with my perspective on how the crisis came about.
The Roots of the Crisis. The crisis has many inter-related causes, and blame can be laid at the
feet of many different parties. Encouraged by the willingness of institutions in the secondary
market to buy their wares, banks and mortgage companies were all too happy to originate
mortgages of lesser quality than previously had been thought appropriate, Having been sold to
the secondary buyers, these mortgages \¡/ere bundled up into packages, then sliced and diced in a
variety of imaginative ways by investment banks, which created and issued securities based on
these bundles, The rating agencies, paid by the issuers, rated these securities, which were then
sold to final buyers or, in some cases, held on the balance sheets of the banks and brokerages.
As time went on, the quality of the newly created mortgages deteriorated to remarkably low
levels, and the rating agencies became increasingly fanciful in their ratings. A1l this took place at
a time when the investment banks and brokerages had moved to a regime of "self-regulation," a
consequence of which was exceptionally leveraged balance sheets. It also took place at a time
when the (unregulated) market for cÍedit default swaps (CDS) expanded rapidly, enabling
holders of the improperly rated securities (and of the debt of others holding them) to purchase
further comfort. At the same time, a huge global pool of investment money, coupled with great
demand for more and more fixed income investment opportunities, pushed everybody in the
chain to create more and more mortgage-backed securities to sell, even if the underlying
mortgages were of questionable quality. All of this worked splendidly as long as home prices
continued to rise rapidly, but when they began to stall and reverse, the party was over. 'We
have
all seen the result.
There is much blame to be shared: the SEC and perhaps the Federal Reserve for taking such a
hands-off position on the leverage posture of the investment banks and the uncontrolled nature of
the CDS market; the players all along the chain of creation and distribution of the paper, each of
whom should have blown a whistle rather than passing the problem on to the next guy; and
finally, and in my opinion the most culpable, the rating agencies, which failed in their duty and
allowed sows' ears to be sold as silk purses.
a -LYour
letter asked me to address several issues specifically relating to the hedge fund industry,
and I will do that in a moment. First, let me tell you a little about myself and my company, a
somewhat atypical investment management firm, Renaissance Technologies LLC
("Renaissance").
Background on Myself and my Company. Renaissance's investment approach is driven by
my background in mathematics. Before I ever entered the business world, I was a
mathematician. I have a PhD from Berkeley, won the 1975 VeblenPnze of the American
Mathematics Society (given every four years for work in geometry and topology), and taught
mathematics at the Massachusetts Institute of Technology and Harvard University before
becoming the chairman of the Mathematics Department at the State University of New York at
Stony Brook. Along the way, I spent four years as a code cracker for the National Security
Agency.
Renaissance, an SEC-registered Investment Adviser since 1998, manages what are termed
quantitative funds - funds whose trading is determined by mathematical formulas designed to
predict market behavior, Individual trades are generated by computers, based on work
continually developed by our researchers. Naturally, human beings carefully monitor the trade
execution process, making sure that all parts of the system are behaving properly. We operate in
only highly liquid, publicly listed securities, such as stocks, bonds, currencies, and commodities,
and do this on exchanges throughout the world. This means, for example, that we do not trade in
credit default swaps or collateralized debt obligations, neither.of which satisfies the above
criteria. In the stock traìing of our Medallion Fund, we hold balanced portfolios in each country,
i.e.,portfolios very close to being equally long and short. Our trading models tend to buy stocks
that are recently out of favor and sell those recently in favor. Thus, to some extent, our actions
-3-
have the effect of dampening extreme moves in either direction, and, as a result, reducing
volatility in those stocks. An example of this contrarian tendency is the fact that during the sixweek
period ending this September, Medallion held long positions in many of the most troubled
of the financial stocks, including Lehman Brothers and Washington Mutual. We of course lost
money on those trades!
Renaissance manages three fund families: Medallion, RIEF and RIFF. The first is our flagship
fund, which we have operated for twenty years with great success. In the early part of this
decade, we determined that the fund had grown too large, and we began to return capital to
investors who were not employees of the firm. That process was completed in 2005, and since
then the fund has been almost entirely owned by the people who operate it - Renaissance
employees. 'We
charge ourselves fees because fund investment is not allocated in the same
proportion as is employee compensation. For example, my share of Medallion is far greater than
is my share of employee compensation. Thus, the fee mechanism moves income away flom the
largest owners of the firm to the rest of the employees. Nearly all of the income of the firm and
its employees is based on the performance of Medallion, a fund whose investors are almost
exclusively its managers.
In recent years, Renaissance started two new funds aimed at outside investors: the Renaissance
Institutional Equities Fund (RIEF) and the Renaissance Institutional Futures Fund (RIFF). The
first is net long one dollar of U.S.-traded stocks for each dollar of equity in the fund and is
designed to be a lower-volatility and higher-return substitute for an index fund, The second is a
slow trading fund, investing in commodities, currencies, bonds, and stock indices, and is
designed to deliver an attractive return at relatively low volatility. RIEF has done a fine job
during its three years plus of existence. RIFF, started 13 months ago, did well during its first
4-
nine months but has been challenged by the turbulence of this fall, during which its returns were
disappointing. Both of these frrnds, designed for institutional investors, are lightly leveraged and
charge fees less than half of those charged by mainstrearn hedge funds. These institutional funds
are a new business for Renaissance, and while their financial contribution to the firm has been
exceptionally modest, we have high hopes for the long term.
I will now tum to the questions the Committee raised.
Do Hedge Funds Cause Systemic Risk? As I have already mentioned, the behavior of
institutions in several financial sectors contributed to the recent crisis, but, in my view, the hedge
fund sector was not among them. While there are exceptions to any rule, I believe that hedge
funds by and large have made an important contribution to the financial industry, and, as
indicated in what follows, are unlikely as a single class to be a substantial contributor to systemic
risk. Generally speaking, hedge funds have provided to the markets an increased level of
liquidity, reduced volatility, improved price discovery, and enhanced the returns of many large
endowments and pension funds. Moreover, by pursuing a rather diverse set of strategies such as
long/short equities trading, convertible bond arbitrage, merger arbitrage, statistical arbitrage,
global macro, distressed debt and workout activities, and old-fashioned deep value investing,
hedge funds are sufficiently spread out that, as a class by itself, they do not seem to present a
source of systemic risk. I say this with the knowledge that hedge funds indeed employ leverage,
and there are doubtless individual examples where this is overdone. Nonetheless, the leverage
posture of each participant in the industry is monitored carefully by its lenders and is controlled
far more stringently than is the ieverage posture of many participants in the investment banking
industry. The latter is subject to no such monitoring and in many cases achieved leverage levels
far in excess of those of hedge funds. The results of such excess are now well known.
-5-
Do Hedge Funds Require Further Regulation? Let me first note that hedge funds are
presently regulated in a variety of ways. For example, the Investment Advisers Act of 1940
imposes anti-fraud requirements on all hedge fund managers. Moreover, they are subject to a
variety of securities position reporting requirements under the Exchange Act. Unlike other
financial institutions that handle investments by the general public, hedge funds (by law) are
accessible only to large and sophisticated investors. Therefore, new regulations focusing on
customer protection, such as apply to mutual funds and brokerage firms, are probably not
necessary or even desirable. On the other hand, I do think that regulation focused on ensuring
market integrity and market stability would be useful and welcome. I will briefly address this
subject below in the section on transparency.
Should Hedge Funds be Registered with the SEC? There has been a gteat deal of discussion
over the last few years about whether hedge fund managers should be required to register with
the SEC as investment advisers. This debate has been a moot point for us, because we
voluntarily registered in 1998. Our business model is relatively simple, and we have not
considered SEC registration to be an undue burden, but other, more tlpical, hedge fund
managers likely have been deterred from such registration because the regulatory authorities
have not always administered the Investment Advisers Act in away that takes account of many
hedge fund managers' business models. If the Committee pursues a registration requirement for
hedge fund managers, I would encourage you to see to it that the design and implementation of
the requirement fit the way our particular industry works'
Should Hedge Funds be more Transparent? Proposals for greater transparency into hedge
funds' investments also have received a great deal of attention lately. We agree that
transparency to appropriate regulators of all market participants can be helpful in monitoring
6-
systemic risk and manipulative practices, In spite of my belief that hedge funds by themselves
are unlikely to be a source of systemic risk, it could be the case that aggregate positions of hedge
funds, together with those of other industry participants, could sometimes present that
possibility. A proposal the Committee may wish to consider is to require hedge funds' positions
to be reported to an appropriate regulator and then to allow the Federal Reserve Bank of New
York, or some similar such authority, to have access to aggregate position information and to
recommend appropriate action should the situation warrant it. I stress, however, that information
so provided by individual funds or institutions should never be released to the general public in
disaggregated form. Such disclosure can serve no useful pu{pose and indeed can cause harm to
small investors, who, unfamiliar with the strategies leading to certain individual positions, may
act upon an eÍoneous understanding of the data.
Does the Compensation Structure of Hedge Funds Lead to Excessive Risk Taking? While
this question does not really apply to us, as almost all of our income is based on profits on our
own capital, generally speaking I would say the answer is no. In the first place, contrary to what
one might think, hedge funds are not a particularly volatile asset class. For example, over the
past ten years the annual volatility of the capital-weighted HFI, the standard hedge fund index,
wasT.2Yo,whereas that of the S&P index was 15.4o/o. From these statistics, one can see that, on
the whole, hedge fund managers turn out to be relatively cautious. Yes, they receive a
performance allocation of 20o/o or 25Yo of profits each year, but if the year.is a loser, those losses
have to be earned back before there are any such allocations in future years. Since most
managers wish to remain in business for a long time, they are unlikely to run the risk of a large
loss (which would lead to massive redemptions and the end of the fund) in the hopes of having
one great year. Moreover, it is typically the case that amanager's largest investment is in his
-7 -
own fund. That is certainly the situation at Renaissance and at most other funds with which I am
familiar.
Is Special Tax Treatment for Hedge Fund Managers'Warranted? With the exception of
offshore deferred compensation, a practice recently prohibited and one in which we never
participated, I know of no speci altaxtreatment for hedge fund managers. It is true that much of
their compensation is via profit allocation from their funds, and this is taxed in the same manner
as profits earned by the fund's investors, but that arrangement is standard in all partnerships,
including, for example, partnerships engaged in manufacturing, services, real estate, and natural
resources businesses. As to whether such income to managers ought to be treated in that manner,
I have no opinion except to observe that partnership taxation has always worked that way. Of
course, if it is good public policy to alter that treatment, it should apply across the board to all
types of partnerships, not simply to hedge funds.
Before concluding, I would like to take this opportunity to reflect on how we may best get out of
this hole, and to make a specific proposal, the implementation of which may prevent us from
ever getting back in.
I believe the most important thing we can do in the near term is to keep as many people as
possible living in the homes they now occupy, even if their mortgages are in default and they
have negative equity in their property. There have been a number of plans put forward to
achieve this end, and I will not opine on which is best, but I will opine on the great importance of
that result. Not only would it provide an important measure of stability to millions of families
who already will be coping with an economy niarked by growing unemploynent and other
destabilizing factors, but it will maintain the values of their homes at a far better level than would
-8-
be the case in foreclosure, thus mitigating the impairment to the trillions of dollars of securities
collateralized by mortgages on these homes. As for the longer'term, I propose the following.
A New Rating Organization. Historically, the bond rating agencies worked for the bond
buyers, being paid through subscriptions to the agencies' publications. This model changed in
the 1970s to one in which the agencies were paid by the bonds' issuers. In spite of the obvious
conflict of interest, the new model worked reasonably well for conventional bonds subject to
conventional financial analysis. The situation changed considerably, however, with the advent
of fi nancially engineered products.
I very much believe in the value of these products, but it is crucial that organizations rating them
are appropriately staffed with personnel well trained in quantitative methods, and, even more
importantly, that the organizations owe their allegiance to the buyers, not the issuers.
I therefore would encourage the major organízations who are the traditional holders of these
bonds, such as CaIPERS, TIAA-CREF and PIMCO, to band together to sponsor a new, not-forprofit
rating organiz,ation, focusing on derivative securities. Representatives of these
organizations could serye on the board of the new organization. Another option might be for
Congress to charter such an organization, in which case representatives of the private entities
might be joined on the board by specified offìcials from the Federal Reserve or other appropriate
goverïrment agencies, Revenues for the new organizationcould come from fees, paid by the
buyer, whenever a transaction took place in a bond rated by the new organization. I believe that
these fees would be miniscule relative to the value of the bond, and every buyer very likely
would insist that merchandise being purchased bear a rating from the new organizalion.
-9
As a result, these complex instruments would be subject to proper analysis and rating, the
interests of buyers and raters once again would be aligned, and the probability of reoeeurrence of
a problem anywhere near the extent of that which we are now facing would be dramatically
reduced.
Again, I appreciate the opportunity to testiffbefore the Committee, and I hopE my testimony has
been helpful.
-10-

Sunday, March 7, 2010

This is confidential - But, My Writing is so Sloppy that it is Illegible

Saturday, March 6, 2010

Sub CycleThrough()
Dim Counter As Integer
Dim Origin As String
Dim BigNum, colNum, BigReduction As Integer
Dim rng As Range
step = InputBox("What is your vertical step?", DefaultValue, 100, 100)
BigNum = InputBox("How many loops?,How Many Times?", DefaultValue = 100, 100, 100)
BigReduction = BigNum
Set rng = Application.InputBox(prompt:="What is your range?", Type:=8)
If rng Is Nothing Then
MsgBox "Operation Cancelled"
Else
rng.Select
End If
GoTo move

what:

Exit Sub
move:
BigReduction = BigNum
For Counter = 1 To BigReduction
BigNum = BigNum + step
Selection.Copy
ActiveCell.Offset(1 + step, 0).Range("a1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False


If MsgBox("Stop Macro?", vbYesNo) = vbYes Then GoTo what


Next Counter

End Sub

Thursday, February 25, 2010

Adobe Flash - ActionScript 3.0 for a Flash Menu Bar with Button and Mouse Events

var timer:Timer = new Timer(25);
timer.addEventListener(TimerEvent.TIMER, followF);
timer.start();

function followF(e:Event):void{
    stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseF);
}
function mouseF(e:MouseEvent):void{
           master_mc.glow_mc.x = stage.mouseX - 56;
           addEventListener(MouseEvent.MOUSE_MOVE, updateF);
           if (mouseX <= 56)
           {
               master_mc.glow_mc.x = 0;
            }
            else if (mouseX >= 787.5)
            {
            master_mc.glow_mc.x = 787.5;
            }
      

function updateF(e:MouseEvent):void{
            e.updateAfterEvent();
}      
//-----------------------Button Code
master_mc.addEventListener(MouseEvent.MOUSE_DOWN, glowStickF);
function glowStickF(e:MouseEvent):void{
master_mc.glow_mc.x = e.target.x;
}
master_mc.home_btn.addEventListener(MouseEvent.CLICK, homeF);  
master_mc.finance_btn.addEventListener(MouseEvent.CLICK, financeF);
master_mc.ec_btn.addEventListener(MouseEvent.CLICK, ecF);
master_mc.technology_btn.addEventListener(MouseEvent.CLICK, techF);
master_mc.business_btn.addEventListener(MouseEvent.CLICK, busF);
master_mc.example_btn.addEventListener(MouseEvent.CLICK, exampleF);
master_mc.programming_btn.addEventListener(MouseEvent.CLICK, blog);
master_mc.articles_btn.addEventListener(MouseEvent.CLICK, articlesF);
      
function ecF(e:MouseEvent):void
{
var ec:URLRequest = new URLRequest("http://www.quantumsupport.biz/Ethan_Castanon.aspx");
navigateToURL(ec, "_self");
}
function homeF(e:MouseEvent):void
{
var home:URLRequest= new URLRequest("http://www.quantumsupport.biz/index.aspx");
navigateToURL(home, "_self");
}
function articlesF(e:MouseEvent):void
{
var links_and_code:URLRequest=new URLRequest("http://www.quantumsupport.biz/links_and_code.html");
navigateToURL(links_and_code, "_blank");
}
function financeF(e:MouseEvent):void
{
var finance:URLRequest=new URLRequest("http://www.quantumsupport.biz/Financial_Services.aspx");  
navigateToURL(finance, "_self");
}
function busF(e:MouseEvent):void
{
var business:URLRequest = new URLRequest("http://www.quantumsupport.biz/Business_Development.aspx");
navigateToURL(business, "_self");
}
function techF(e:MouseEvent):void
{
var technology:URLRequest= new URLRequest("http://www.quantumsupport.biz/Information_Technology.aspx");
navigateToURL(technology, "_self");
}
function exampleF(e:MouseEvent):void
{
var dadsiteexample:URLRequest= new URLRequest("http://www.drcastanon.com");
navigateToURL(dadsiteexample, "_blank");
}
function blog(e:MouseEvent):void
{
var bloglink:URLRequest = new URLRequest("http://quantumsupport.blogspot.com");
navigatetonewURL(bloglink,"_blank");
}
}

Tuesday, February 23, 2010

Properly Using a Sub Procedure in Microsoft Office Excel - Visual Basic for Applications

Option Explicit
Sub callMacros()

MacroInteger 7

MacroString "a String"

MacroIntegerString 4, "some string"

End Sub




Sub MacroInteger(I As Integer)

MsgBox "Integer i=" & I

End Sub



Sub MacroString(S As String)

MsgBox "String value=" & S

End Sub



Sub MacroIntegerString(I As Integer, S As String)

MsgBox "I=" & I & ", S=" & S

End Sub

VBA - Loop Downward Sequentially by 13 Rows and Enter a Formula that Changes Sequentially and Format it by Subscripting Some Characters

Sub CycleThrough()
Dim Counter As Integer
Dim Origin As String
Dim BigNum, colNum, BigReduction As Integer
Dim rng As Range
Dim ii As Integer
Dim e, output As String
e = "T"
On Error GoTo what
step = InputBox("What is your vertical step?", DefaultValue, 100, 100)
BigNum = InputBox("How many loops?,How Many Times?", DefaultValue = 100, 100, 100)
BigReduction = BigNum
Set rng = Application.InputBox(prompt:="What is your range?", Type:=8)
If rng Is Nothing Then
MsgBox "Operation Cancelled"
Else
rng.Select
End If
GoTo move

what:

Exit Sub
move:
ii = 0
BigReduction = BigNum
For Counter = 1 To BigReduction
BigNum = BigNum + step
ii = ii + 1
output = e & ii

ActiveCell.Value = output
With ActiveCell.Characters(Start:=2, Length:=2).font
.Name = "Calibri"
.FontStyle = "Regular"
.Size = 22
.Strikethrough = False
.Superscript = False
.Subscript = True
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
ActiveCell.Offset(step, 0).Range("a1").Select

If MsgBox("Stop Macro?", vbYesNo) = vbYes Then GoTo what


Next Counter

End Sub

Create a Subscript by Macro

Sub Macro12()
'
' Macro12 Macro
'

'
Range("A204").Select
ActiveCell.FormulaR1C1 = "T14"
With ActiveCell.Characters(Start:=1, Length:=1).font
.Name = "Calibri"
.FontStyle = "Regular"
.Size = 22
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
With ActiveCell.Characters(Start:=2, Length:=2).font
.Name = "Calibri"
.FontStyle = "Regular"
.Size = 22
.Strikethrough = False
.Superscript = False
.Subscript = True
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
Range("D204").Select
End Sub

Macro - Format Painter - Copy - Jump Downward 13 Rows and Paste Formatting

Sub format_painter()
'
' format_painter Macro
'

'
Selection.Copy
ActiveWindow.SmallScroll Down:=16
ActiveCell.Offset(13, 0).Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
End Sub

Mathematica Link to Microsoft Office Excel for Interconnecting the Two - Extremely Powerful Combination

Mathematica Link for Excel 3.2

Bringing the Power of Mathematica to Excel




With Mathematica Link for Excel, you can have it all: All of
the power and sophistication of Mathematica. All of the
familiarity and convenience of Excel. Mathematica Link for
Excel
eliminates the complexities of bridging the two programs,
giving you the best of both worlds.


Mathematica Link for Excel adds over a thousand functions and
options to Excel and lets you interactively explore them using the
Mathematica function wizard. Excel formulas can suddenly perform
symbolic computations, find complex roots, plot equations, and much more.
Displaying Mathematica graphics and typesetting equations in
Excel is as easy
as entering a formula. Data and equations can be visualized in new and
insightful ways that are not possible in Excel alone.




Key Features

Mathematica Link for Excel is a fully bidirectional link
that can be used to:

  • Create spreadsheet formulas that call Mathematica from within
    Excel
  • Write code in Mathematica that interacts with and automates
    Excel
  • Call Mathematica code as if it were an Excel macro
  • Develop customized Excel import and export routines in
    Mathematica
  • Copy and paste between Mathematica and Excel
  • Display Mathematica graphics and typeset expressions in
    Excel



Forget about creating cumbersome temporary data files—instead, you
can easily copy and paste data between Mathematica and Excel.
Experience unparalleled "side-by-side" use of both programs as you
programmatically read and write data from Mathematica notebooks
to Excel workbooks, even ones that are currently open in Excel. You
can also convert Mathematica notebooks into Excel macros in
just a few simple steps.


Get the best of both worlds with Mathematica Link for Excel.




About the Developer

Episoft is a California-based corporation specializing in easy-to-use
productivity, connectivity, and analysis tools for today's extensible
desktop. In addition to commercial software, Episoft provides customized
software solutions and on-site training to a broad range of industries.
Past clients include General Electric, Lucent Technologies, Aerospace
Corporation, Beringer Winery, and the United States Department of Defense.

Episoft was founded in 1997.




Product Support

Mathematica Link for Excel is developed and supported by Episoft, Inc.


Episoft, Inc.

40258 Highway 41, Suite A

Oakhurst, CA 93644

email inquiry@episoft.com




Mathematica Link for Excel 3.2 requires Mathematica 6 or 7
and
Excel 2000 or higher, and is available for Windows 2000/XP/Vista.




Mathematica Link for Excel is © 1998-2009 Episoft, Inc.


 


Mathematica 6 compatible version coming soon!
Buy now and receive a free upgrade















 © 2010 Wolfram Research, Inc. • Terms of Use • Privacy Policy 









Monday, February 22, 2010

Robust Userform Macro - Load it Up

Application Run Method - Powerful & Universal in VBA

To Use the Application.Run Method
You can use the Application.Run method to run Visual Basic Sub procedures or Microsoft Excel version 4.0 macros from other Visual Basic procedures. The Application.Run method requires one named argument: the name of the macro or Sub procedure to be run. (However, other optional arguments may also be included.) This name can be a text string (for example, "TestXLM") or it can be a variable that is equal to the name of the macro.

For example, to run a Microsoft Excel version 4.0 macro called TestXLM, you could use this method:
Application.Run ("TestXLM")

If you have the variable "MacroToRun" set to "TestXLM," you could use this method:
Application.Run (MacroToRun)

Thank you,

Ethan Castanon
Quantum Support – The Union of Finance & Technology
17732 Beach Blvd., Suite D
Huntington Beach, CA 92647
949-945-8665
Email: ethan@quantumsupport.biz
Web: http://www.quantumsupport.biz

Select Case - VBA - Microsoft Excel Visual Basic for Applications Programming - Programming Concepts

Create a New Workbook by Macro

Sub NewBook()

Dim NwBkName As Variant
Dim NewBook As Workbook
Set NewBook = Workbooks.Add

NewBook.SaveAs Filename:="C:\Users\crowbar\Documents\fund work\final\temp.xlsx"



NewBook.Activate

Automate Cut and Paste - In Cases Where Their is a Clear Pattern -

Sub CutNPaste()
ActiveCell.Select
sclng = ActiveCell.Copy
ActiveCell.Offset(1, -1).Select
ActiveCell.PasteSpecial xlPasteAll

Delete Rows Based on Criteria

Sub Find_and_delete()
Dim rng As Range
Dim what As String
Dim strMsg As String
Dim lok4 As String
Dim count As Integer
count = 0
lok4 = Application.InputBox("What variable?")
Do
Set rng = ActiveSheet.UsedRange.Find(lok4)
If rng Is Nothing Then
Exit Do
Else: Rows(rng.Row).Delete
count = (count + 1)

End If
Loop
MsgBox "The number of deleted cells was " & count


End Sub

Thank you,

Ethan Castanon
Quantum Support – The Union of Finance & Technology
17732 Beach Blvd., Suite D
Huntington Beach, CA 92647
949-945-8665
Email: ethan@quantumsupport.biz
Web: http://www.quantumsupport.biz

Excel - Move To a Range Away at a Specified Interval and Automate Cut & Paste Operations

Sub adder()
'
' adder Macro
'

'
Selection.Copy
ActiveCell.Offset(7, 0).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlAdd, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Selection.Copy
ActiveCell.Offset(7, 0).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlAdd, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Selection.Copy
End Sub

Thank you,

Ethan Castanon
Quantum Support – The Union of Finance & Technology
17732 Beach Blvd., Suite D
Huntington Beach, CA 92647
949-945-8665
Email: ethan@quantumsupport.biz
Web: http://www.quantumsupport.biz

Excel - VBA - Microsoft Office Excel 2010 - Automation - Customization - UserForms Retrieving Computed Results

Excel - VBA - Microsoft Office Excel 2010 - Perform Operations Sequentially Downward at Any Specified Jump Factor and Any Entered Loop Count

Sub CycleThrough()
Dim Counter As Integer
Dim Origin As String
Dim BigNum, colNum, BigReduction As Integer
Dim rng As Range
step = InputBox("What is your vertical step?", DefaultValue, 100, 100)
BigNum = InputBox("How many loops?,How Many Times?", DefaultValue = 100, 100, 100)
BigReduction = BigNum
Set rng = Application.InputBox(prompt:="What is your range?", Type:=8)
If rng Is Nothing Then
MsgBox "Operation Cancelled"
Else
rng.Select
End If
GoTo move

what:

Exit Sub
move:
BigReduction = BigNum
For Counter = 1 To BigReduction
BigNum = BigNum + step
Selection.Copy
ActiveCell.Offset(1 + step, 0).Range("a1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False


If MsgBox("Stop Macro?", vbYesNo) = vbYes Then GoTo what


Next Counter

End Sub

Thank you,

Ethan Castanon
Quantum Support – The Union of Finance & Technology
17732 Beach Blvd., Suite D
Huntington Beach, CA 92647
949-945-8665
Email: ethan@quantumsupport.biz
Web: http://www.quantumsupport.biz

asp.net - c# - sql

DeleteCommand="DELETE FROM [aedha_pts] WHERE [PatientID] = ?"
InsertCommand="INSERT INTO [aedha_pts] ([PatientID], [FirstName], [LastName], [DOB], [Issue], [Street], [City], [State], [Zip], [Phone1], [Phone2], [Email], [Insurance], [PaymentForm], [PaymentAmount], [COGS], [EvalDate], [DelivDate], [Warranty], [Notes]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
ProviderName="<%$ ConnectionStrings:quantbusConnectionString.ProviderName %>"
SelectCommand="SELECT [PatientID], [FirstName], [LastName], [DOB], [Issue], [Street], [City], [State], [Zip], [Phone1], [Phone2], [Email], [Insurance], [PaymentForm], [PaymentAmount], [COGS], [EvalDate], [DelivDate], [Warranty], [Notes] FROM [aedha_pts]"
UpdateCommand="UPDATE [aedha_pts] SET [FirstName] = ?, [LastName] = ?, [DOB] = ?, [Issue] = ?, [Street] = ?, [City] = ?, [State] = ?, [Zip] = ?, [Phone1] = ?, [Phone2] = ?, [Email] = ?, [Insurance] = ?, [PaymentForm] = ?, [PaymentAmount] = ?, [COGS] = ?, [EvalDate] = ?, [DelivDate] = ?, [Warranty] = ?, [Notes] = ? WHERE [PatientID] = ?">
















































Excel VBA - Functions

Function EndingMktVal(EndW As Single, ETFprcAtExp, CallStk, CallExPrice, CallPriceAtEntry, CallCalled, PutStk, PutCalled, PutExPrice, PutPriceAtEntry)


Dim EndValETF, PutPrem, CallPrem, CallDmg, PutDmg As Currency
Dim RedEndQ As Variant



RedEndQ = ((EndW / 100) * 100)
EndValETF = RedEndQ * ETFprcAtExp
CallPremium = RedEndQ * CallPrc
PutPremium = RedEndQ * PutPrc
CallDmg = ((RedEndQ * (ETFprcAtExp - CallStk)) + CallPremium)
PutDmg = ((RedEndQ * (PutStk - ETFprcAtExp)) + PutPremium)


If (CallCalled = "No" Or CallCalled = "no" And PutCalled = "No" Or PutCalled = "no") Then
EndingMktVal = EndValETF + CallInMoney + PutInMoney
ElseIf (CallCalled = "Yes" Or CallCalled = "yes" And PutCalled = "No" Or PutCalled = "no") Then
EndingMktVal = EndValETF + PutPremium + CallDmg
ElseIf (CallCalled = "No" Or CallCalled = "no" And PutCalled = "Yes" Or PutCalled = "yes") Then
EndingMktVal = EndValETF + CallPremium + PutDmg
ElseIf (CallCalled = "Yes" Or CallCalled = "yes" And PutCalled = "Yes" Or PutCalled = "yes") Then
EndingMktVal = EndValETF + CallDmg + PutDmg

End If
End Function

==================================================================

























Function SNorm(z)

Application.ScreenUpdating = False

c1 = 2.506628
c2 = 0.3193815
c3 = -0.3565638
c4 = 1.7814779
c5 = -1.821256
c6 = 1.3302744
If z > 0 Or z = 0 Then
w = 1
Else: w = -1
End If
y = 1 / (1 + 0.2316419 * w * z)
SNorm = 0.5 + w * (0.5 - (Exp(-z * z / 2) / c1) * _
(y * (c2 + y * (c3 + y * (c4 + y * (c5 + y * c6))))))

Application.ScreenUpdating = True

End Function

'**********************************************************************
'* Black-Scholes European Call Price Computation *
'**********************************************************************

Function Call_Eur(s, x, t, r, sd)

Application.ScreenUpdating = False
Dim a As Single
Dim b As Single
Dim c As Single
Dim d1 As Single
Dim d2 As Single

a = Log(s / x)
b = (r + 0.5 * sd ^ 2) * t
c = sd * (t ^ 0.5)
d1 = (a + b) / c
d2 = d1 - sd * (t ^ 0.5)
Call_Eur = s * SNorm(d1) - x * Exp(-r * t) * SNorm(d2)

Application.ScreenUpdating = True

End Function

'*********************************************************************
'* Black-Scholes European Put Price Computation *
'*********************************************************************

Function Put_Eur(s, x, t, r, sd)

Application.ScreenUpdating = False


Dim a As Single
Dim b As Single
Dim c As Single
Dim d1 As Single
Dim d2 As Single

a = Log(s / x)
b = (r + 0.5 * sd ^ 2) * t
c = sd * (t ^ 0.5)
d1 = (a + b) / c
d2 = d1 - sd * (t ^ 0.5)
CallEur = s * SNorm(d1) - x * Exp(-r * t) * SNorm(d2)
Put_Eur = x * Exp(-r * t) - s + CallEur

Application.ScreenUpdating = True

End Function
Equals (=)
Less than (<) Less than or equal to (<=) Greater than (>)
Greater than or equal to (>=)
Not equal to (<>)

Excel - VBA - Named Ranges


Working With Names In Visual Basic
You can use VBA code to work with defined names. To add a name, use
ThisWorkbook.Names.Add Name:="SomeName", _
    RefersTo:=Worksheets("Sheet2").Range("A1:A10")
This will assign the Name SomeName to the range A1:A10 on Sheet2. If you add a Name that already exists, the Name is automatically deleted and recreated with the new reference. It is not necessary to delete the Name before recreating it.
By default, names created manually or with VBA code are visible -- they will appear in the Name Box drop down and in the Names dialog. You can, however, make the name hidden so that it isn't visible to the user. A hidden Name can be used in any manner just like a normal, visible Name. To make a name hidden, you set the Visible parameter to False. For example,
ThisWorkbook.Names.Add Name:="SomeName2", _
    RefersTo:=Worksheets("Sheet2").Range("B1:B10"), _
    Visible:=False
The name SomeName2 can be used exactly as a visible name, but will not appear to the user. The only way to hide a Defined Name is via VBA code. There is nothing in the Excel user interface that allows you to hide a Name.
To delete a name using VBA code, use code like the following:
ThisWorkbook.Names("TheName").Delete
Using Defined Names in VBA code is different than using them in worksheet cells. You must get the value of the Name using the RefersTo or RefersToRange properties. If a Name doesn't refer to a cell or range of cells (e.g., it refers to a constant), an attempt to use RefersToRange will fail. To get the value of a Name that contains a constant, use the RefersTo property.
V = ThisWorkbook.Names("TheName").RefersToRange
If the name refers to a range of 2 or more cells, you can assign it to a Range type variable. For example,
Dim R As Range
Set R = ThisWorkbook.Names("BigName").RefersToRange
Debug.Print R.Address
If the name refers to a constant, you'll need to strip out some characters to get the actual value. For example, if the name MyName refers to the text constant Chip Pearson, the RefersTo property will return the text ="Chip Pearson". You need to strip out the leading equals sign and the enclosing quotes. You can do this with code like the following:
Dim S As String
S = ThisWorkbook.Names("MyName").RefersTo
S = Mid(S, 3, Len(S) - 3)
Debug.Print S
If the name refers to a numeric constant, there will be a leading equal sign but no quotes. Thus, you'll need to strip off the leading equals sign. The code below illustrates this.
Dim S As String
S = ThisWorkbook.Names("MaxPages").RefersTo
S = Mid(S, 2)
Debug.Print S
We can put all this together into a function that will return what the given name refers to, be it a range, text constant, or numeric constant.
Function GetNameRefersTo(TheName As String) As String
    Dim S As String
    Dim HasRef As Boolean
    Dim R As Range
    Dim NM As Name
    Set NM = ThisWorkbook.Names(TheName)
    On Error Resume Next
    Set R = NM.RefersToRange
    If Err.Number = 0 Then
        HasRef = True
    Else
        HasRef = False
    End If
    If HasRef = True Then
        S = R.Text
    Else
        S = NM.RefersTo
        If StrComp(Mid(S, 2, 1), Chr(34), vbBinaryCompare) = 0 Then
            ' text constant
            S = Mid(S, 3, Len(S) - 3)
        Else
            ' numeric contant
            S = Mid(S, 2)
        End If
    End If
    GetNameRefersTo = S
End Function

Macros, Macros, Macros - Excel - Visual Basic for Applications Programming

Automation is the future -
Below you will find VBA macros to be used in Microsoft Office Excel with their associated descriptions -
----------------------------------------------------------------------------------------------------------
Load up an Excel UserForm with Drop Down Combo Boxes

=================================================================
Private Sub CommandButtonSubmit_Click()
Dim port As Currency
Dim bg_dbc_st, bg_eem_st, bg_efa_st, bg_iwm_st, bg_iyr_st, bg_mdy_st, bg_spy_st As Currency
Dim md_dbc_st, md_eem_st, md_efa_st, md_iwm_st, md_iyr_st, md_mdy_st, md_spy_st As Currency
Dim nd_dbc_st, nd_eem_st, nd_efa_st, nd_iwm_st, nd_iyr_st, nd_mdy_st, nd_spy_st As Currency
Dim beginNum, endNum, thirteen_add, loop_counter As Integer
Dim dbc_st, eem_st, efa_st, iwm_st, iyr_st, mdy_st, spy_st As Single
Application.ScreenUpdating = False
Worksheets("Home").Range("bz2").Select
loop_counter = ActiveCell.Value
ActiveCell.Value = (ActiveCell.Value + 1)





If start_int_cmbo.Value = "T1" Then
    beginNum = 1
ElseIf start_int_cmbo.Value = "T2" Then
    beginNum = 2
ElseIf start_int_cmbo.Value = "T3" Then
    beginNum = 3
ElseIf start_int_cmbo.Value = "T4" Then
    beginNum = 4
ElseIf start_int_cmbo.Value = "T5" Then
    beginNum = 5
ElseIf start_int_cmbo.Value = "T6" Then
    beginNum = 6
ElseIf start_int_cmbo.Value = "T7" Then
    beginNum = 7
ElseIf start_int_cmbo.Value = "T8" Then
    beginNum = 8
ElseIf start_int_cmbo.Value = "T9" Then
    beginNum = 9
ElseIf start_int_cmbo.Value = "T10" Then
    beginNum = 10
ElseIf start_int_cmbo.Value = "T11" Then
    beginNum = 11
ElseIf start_int_cmbo.Value = "T12" Then
    beginNum = 12
ElseIf start_int_cmbo.Value = "T13" Then
    beginNum = 13
ElseIf start_int_cmbo.Value = "T14" Then
    beginNum = 14
ElseIf start_int_cmbo.Value = "T15" Then
    beginNum = 15
ElseIf start_int_cmbo.Value = "T16" Then
    beginNum = 16
ElseIf start_int_cmbo.Value = "T17" Then
    beginNum = 17
ElseIf start_int_cmbo.Value = "T18" Then
    beginNum = 18
ElseIf start_int_cmbo.Value = "T19" Then
    beginNum = 19
ElseIf start_int_cmbo.Value = "T20" Then
    beginNum = 20
ElseIf start_int_cmbo.Value = "T21" Then
    beginNum = 21
ElseIf start_int_cmbo.Value = "T22" Then
    beginNum = 22
ElseIf start_int_cmbo.Value = "T23" Then
    beginNum = 23
ElseIf start_int_cmbo.Value = "T24" Then
    beginNum = 24
ElseIf start_int_cmbo.Value = "T25" Then
    beginNum = 25
ElseIf start_int_cmbo.Value = "T26" Then
    beginNum = 26
ElseIf start_int_cmbo.Value = "T27" Then
    beginNum = 27
ElseIf start_int_cmbo.Value = "T28" Then
    beginNum = 28
ElseIf start_int_cmbo.Value = "T29" Then
    beginNum = 29
ElseIf start_int_cmbo.Value = "T30" Then
    beginNum = 30
ElseIf start_int_cmbo.Value = "T31" Then
    beginNum = 31
ElseIf start_int_cmbo.Value = "T32" Then
    beginNum = 32
ElseIf start_int_cmbo.Value = "T33" Then
    beginNum = 33
ElseIf start_int_cmbo.Value = "T34" Then
    beginNum = 34
ElseIf start_int_cmbo.Value = "T35" Then
    beginNum = 35
ElseIf start_int_cmbo.Value = "T36" Then
    beginNum = 36
End If

If end_int_cmbo.Value = "T1" Then
    endNum = 1
ElseIf end_int_cmbo.Value = "T2" Then
    endNum = 2
ElseIf end_int_cmbo.Value = "T3" Then
    endNum = 3
ElseIf end_int_cmbo.Value = "T4" Then
    endNum = 4
ElseIf end_int_cmbo.Value = "T5" Then
    endNum = 5
ElseIf end_int_cmbo.Value = "T6" Then
    endNum = 6
ElseIf end_int_cmbo.Value = "T7" Then
    endNum = 7
ElseIf end_int_cmbo.Value = "T8" Then
    endNum = 8
ElseIf end_int_cmbo.Value = "T9" Then
    endNum = 9
ElseIf end_int_cmbo.Value = "T10" Then
    endNum = 10
ElseIf end_int_cmbo.Value = "T11" Then
    endNum = 11
ElseIf end_int_cmbo.Value = "T12" Then
    endNum = 12
ElseIf end_int_cmbo.Value = "T13" Then
    endNum = 13
ElseIf end_int_cmbo.Value = "T14" Then
    endNum = 14
ElseIf end_int_cmbo.Value = "T15" Then
    endNum = 15
ElseIf end_int_cmbo.Value = "T16" Then
    endNum = 16
ElseIf end_int_cmbo.Value = "T17" Then
    endNum = 17
ElseIf end_int_cmbo.Value = "T18" Then
    endNum = 18
ElseIf end_int_cmbo.Value = "T19" Then
    endNum = 19
ElseIf end_int_cmbo.Value = "T20" Then
    endNum = 20
ElseIf end_int_cmbo.Value = "T21" Then
    endNum = 21
ElseIf end_int_cmbo.Value = "T22" Then
    endNum = 22
ElseIf end_int_cmbo.Value = "T23" Then
    endNum = 23
ElseIf end_int_cmbo.Value = "T24" Then
    endNum = 24
ElseIf end_int_cmbo.Value = "T25" Then
    endNum = 25
ElseIf end_int_cmbo.Value = "T26" Then
    endNum = 26
ElseIf end_int_cmbo.Value = "T27" Then
    endNum = 27
ElseIf end_int_cmbo.Value = "T28" Then
    endNum = 28
ElseIf end_int_cmbo.Value = "T29" Then
    endNum = 29
ElseIf end_int_cmbo.Value = "T30" Then
    endNum = 30
ElseIf end_int_cmbo.Value = "T31" Then
    endNum = 31
ElseIf end_int_cmbo.Value = "T32" Then
    endNum = 32
ElseIf end_int_cmbo.Value = "T33" Then
    endNum = 33
ElseIf end_int_cmbo.Value = "T34" Then
    endNum = 34
ElseIf end_int_cmbo.Value = "T35" Then
    endNum = 35
ElseIf end_int_cmbo.Value = "T36" Then
    endNum = 36
End If


On Error GoTo Blanks
bg_dbc_st = (DBC_interval_w8_start.Value / 100)
bg_eem_st = (EEM_interval_w8_start.Value / 100)
bg_efa_st = (EFA_interval_w8_start.Value / 100)
bg_iwm_st = (IWM_interval_w8_start.Value / 100)
bg_iyr_st = (IYR_interval_w8_start.Value / 100)
bg_mdy_st = (MDY_interval_w8_start.Value / 100)
bg_spy_st = (SPY_interval_w8_start.Value / 100)
Blanks:
MsgBox "Blanks values aren't acceptable.  Please make entries: zero is ok for blanks."
Exit Sub

If (100 * (bg_dbc_st + bg_eem_st + bg_efa_st + bg_iwm_st + bg_iyr_st + bg_mdy_st + bg_spy_st) <> 100) Then GoTo Pass

Worksheets("Home").Range("bz2").Select
loop_counter = ActiveCell.Value
ActiveCell.Value = loop_counter + 1
Worksheets("Home").Cells(3, loop_counter + 79).Value = (bg_dbc_st * 100)
Worksheets("Home").Cells(4, loop_counter + 79).Value = (bg_eem_st * 100)
Worksheets("Home").Cells(5, loop_counter + 79).Value = (bg_efa_st * 100)
Worksheets("Home").Cells(6, loop_counter + 79).Value = (bg_iwm_st * 100)
Worksheets("Home").Cells(7, loop_counter + 79).Value = (bg_iyr_st * 100)
Worksheets("Home").Cells(8, loop_counter + 79).Value = (bg_mdy_st * 100)
Worksheets("Home").Cells(9, loop_counter + 79).Value = (bg_spy_st * 100)
thirteen_add = 5
For a_counter = beginNum To endNum
    thirteen_add = (thirteen_add + 13)
    begin_c_val = (thirteen_add + 5)
    Sheets("Home").Cells(begin_c_val, 5).Select
    ActiveCell.Value = bg_dbc_st * Sheets("Home").Cells(thirteen_add, 22)
    Sheets("Home").Cells(begin_c_val + 1, 5).Select
    ActiveCell.Value = bg_eem_st * Sheets("Home").Cells(thirteen_add, 22)
    Sheets("Home").Cells(begin_c_val + 2, 5).Select
    ActiveCell.Value = bg_efa_st * Sheets("Home").Cells(thirteen_add, 22)
    Sheets("Home").Cells(begin_c_val + 3, 5).Select
    ActiveCell.Value = bg_iwm_st * Sheets("Home").Cells(thirteen_add, 22)
    Sheets("Home").Cells(begin_c_val + 4, 5).Select
    ActiveCell.Value = bg_iyr_st * Sheets("Home").Cells(thirteen_add, 22)
    Sheets("Home").Cells(begin_c_val + 5, 5).Select
    ActiveCell.Value = bg_mdy_st * Sheets("Home").Cells(thirteen_add, 22)
    Sheets("Home").Cells(begin_c_val + 6, 5).Select
    ActiveCell.Value = bg_spy_st * Sheets("Home").Cells(thirteen_add, 22)
Next a_counter


Pass:
MsgBox "The weights do not add up to 100%.  Please make the necessary corrections, and resubmit."
Exit Sub
Sheets("Home").Cells(1, 1).Select
Application.ScreenUpdating = True
MsgBox "start_int_cmbo box value is " & start_int_cmbo.Value & vbCrLf & "start number equals " & beginNum & vbCrLf & "end number equals " & endNum & vbCrLf & "bg_dbc_st value is " & bg_dbc_st & vbCrLf & "Loop Counting Value is: " & loop_counter & vbCrLf & vbInformation


End Sub

Thursday, January 21, 2010

But the "Masters of the Minutia" Say "The Indicators Reveal We Are in the Early Stages of a Recovery" - I Would Like Them to Submit to IQ Tests




"Masters of the Minutia" is the Designation I Proscribe All of the Purported Authorities in Various Disciplines Who Either Know Not of Their Profound Mental Deficiency or Care Not of Their Profound Moral Deficiency, as evidenced by what would then be intentional lying motivated by self-interest.


The Fed lies on all of its released statistics because it needs to understate inflation to reduce its interest payments on the trillions of dollars of outstanding Treasury bills, notes and bonds - in addition to avoiding what they have brought within 5 inches of our doorstep - an impending, hyperinflationary great depression that would be the result of other countries dumping the 50%+ U.S. dollars that exist in circulation outside of the United States.

The United States doesn't have any way to repay all of its debt but to devalue the dollar, which destroys those countries' investments in our country.

In any event, I'd just like our "leaders" to be honest.  Lying doesn't solve the problem, regardless of deranged economic policies that state boosting public sentiment will miraculously pull the economy out of Marianas Trench:  That's like saying that the ostrich's practice of sticking its head into a hole to avoid danger is an effective policy.




Sunday, January 17, 2010

Assembly Programming - Good Tutorial by a Knowledgeable Guy

http://www.xs4all.nl/~smit/asm01001.htm

===================================================================


Assembly Tutorial


"This is for all you folks out there, who want to learn the magic art of Assembly programming." - MAD

Index of Section 1

Ready To Start
Memory Segmentation
Code Example
The Stack
The Naming Convention
Main Page
Next Chapter
First thing you need to know is that Assembly is a great, fast language, but only if you put time and effort in learning it. You must give all or nothing. (I suggest you give all) And remember, the beginning is always borring and hard...so don't give up !
Well, I'll start with the basics, like instruction format and some simple instructions to manipulate registers. I don't know how much you know about coding, so I'll explain even the most simple stuff. Please note, that I explain 8086 assembly coding. That means NO 32-bit registers and instructions and NO protected-, real- and virtual 86 mode for now.


Ready to Start!

First of all, we'll talk about the registers and then about the instructions to manipulate (change) them. The 8086 has 14 16-bit registers, all with different usage (see below). You might not understand some of the registers purposes, but be patient, I'll explain everything later.

Segment Registers
CS Code Segment16-bit number that points to the active code-segment
DSData Segment16-bit number that points to the active data-segment
SSStack Segment16-bit number that points to the active stack-segment
ESExtra Segment16-bit number that points to the active extra-segment
Pointer Registers
IPInstruction Pointer16-bit number that points to the offset of the next instruction
SPStack Pointer16-bit number that points to the offset that the stack is using
BPBase Pointerused to pass data to and from the stack
General-Purpose Registers
AXAccumulator Registermostly used for calculations and for input/output
BXBase RegisterOnly register that can be used as an index
CXCount Registerregister used for the loop instruction
DXData Registerinput/output and used by multiply and divide
Index Registers
SISource Indexused by string operations as source
DIDestination Indexused by string operations as destination
(The general purpose registers can be "split". You have the AH and the AL register for example. AH contains the high byte of AX and AL contains the lowbyte. You also have: BH, BL, CH, CL, DL, DH So if eg. DX contains the value 1234h DH would be 12h and DL would be 34h).
And a 16-bit FLAG Register. All "flags" (see below) are stored here. The FLAGS Register consists of 9 status bits. These bits are also called flags, because they can either be SET (1) or NOT SET (0). All these flags have a name and purpose.

Flags Register
Abr.Namebit nºDescription
OFOverflow Flag11indicates an overflow when set
DFDirection Flag10used for string operations to check direction
IFInterrupt Flag9if set, interrupt are enabled, else disabled
TFTrap Flag8if set, CPU can work in single step mode
SFSign Flag7if set, resulting number of calculation is negative
ZFZero Flag6if set, resulting number of calculation is zero
AFAuxiliary Carry4some sort of second carry flag
PFParity Flag2indicates even or odd parity
CFCarry Flag0contains the left-most bit after calculations
Test it!
If you want to see all these register and flags, you can go to DOS and then start "debug" (just type debug) When you're in debug, just type "r" and you'll see all the registers and some abreviations for the flags. Type "q" to quit again. We won't use debug to program in this tutorial, we'll use a real assembler. I use TASM 3.2, but MASM or any other assembler works just fine too.


[Back] [Index]

Memory Segmentation

Now I've to explain something about the way the 8086 uses memory (actually about how DOS uses memory). Since the databus of the 8086 is 16-bits, it can move and store 16-bits (1 word=2 bytes) at a time. If the processor stores a "word" (16-bits) it stores the bytes in reverse order in the memory. It looks like this:
1234h (word) ---> memory 34h (byte) 12h (byte)
So if the memory looks like this: 78h 56h and you get a word from memory you'll get the value 5678h. (note, I use the "h" after a number to indicate it's hexadecimal) However, if you just get a byte from memory it goes this way: memory 78h 56h -----> first byte you get 78h. Okay, pretty clear huh?
Now let's talk about segments. The 8086 divides it's memory into segments. Segments are (standard in DOS) 64 KB big and have a number. These numbers are stored in the segment registers (see above). Three main segments are the code, data and stack segment. Segments overlap each other almost completely. If you start debug again and type "d" you can see some addresses at the left of the screen. The format is like this: 4576:0100. that's a memory address. The first number is the segment number and the second number is the offset within the segment. So FFFF:FFF0 means: Segment FFFFh and FFF0h bytes from the beginning of the segment.
As I said before, segments overlap. The address 0000:0010 is EXACTLY the same address as 0001:0000. That means that segment begin at paragraph boundaries. (a paragraph=16 bytes, so the segment starts at an address divisible by 16) Now you can start calculating REAL addresses in memory. An example: 0000:0010 means: segment 0000h offset 10h Now we multiply the segment number with 16 and add the offset.
Note that the offset 10h means the value 16 in decimal: (0 * 16 = 0 + 16 = 16) this is the linear address.
Next, the other address 0001:0000: (16 * 1 = 16 + 0 = 16). Same linear address! Like I told you. These are some basic things you need to know when you want to program in Assembly. Learn the registers and flags by heart and try to understand the segmentation of memory.
By The Way, this segmentation of memory is actually done by DOS at startup. On a 286 or higher, you have something called real-mode and protected-mode. This Segment explanation is based on Real-mode, in Protected-mode it's way different, but don't bother, that's real complicated stuff you don't need to know. Just assume that what I explained about segments is ALWAYS true. But remember in the back of your head, that there's more.... Trust me...... I know what I'm talking about.

[Back] [Index]

Our first program

Our first program will be a real simple one. I'll first give you the code and then I'll explain it. Here's the code, cut it out and put it in a file called FIRST.ASM. Download the source.

.model small
.stack
.data
message   db "Hello world, I'm learning Assembly !!!", "$"

.code

main   proc
   mov   ax,seg message
   mov   ds,ax

   mov   ah,09
   lea   dx,message
   int   21h

   mov   ax,4c00h
   int   21h
main   endp
end main

You can assemble this by typing: "tasm first [enter] tlink first [enter]" or something like: "masm first [enter] link first [enter] You must have an assembler and the link/tlink program. I'll explain the code now.
.model small : Lines that start with a "." are used to provide the assembler with infomation. The word(s) behind it say what kind of info. In this case it just tells the assembler the program is small and doesn't need a lot of memory. I'll get back on this later.
.stack : Another line with info. This one tells the assembler that the "stack" segment starts here. The stack is used to store temporary data. It isn't used in the program, but it must be there, because we make an .EXE file and these files MUST have a stack.
.data : indicates that the data segment starts here and that the stack segment ends there.
.code : indicates that the code segment starts there and the data segment ends there.
main proc : Code must be in procedures, just like in C or any other language. This indicates a procedure called main starts here. main endp states that the procedure is finished. Procedures MUST have a start and end. end main : tells the assembler that the program is finished. It also tells the assembler were to start the program. At the procedure called main in this case.
message db "xxxx" : DB means Define Byte and so it does. In the data-segment it defines a couple of bytes. These bytes contain the information between the brackets. "Message" is a name to indentify this byte-string. It's called an "indentifier".
mov ax, seg message : AX is a register. You use registers all the time, so that's why you had to know about them before I could explain this. MOV is an instruction that moves data. It can have a few "operands" (don't worry, I'll explain these names later) Here the operands are AX and seg message. Seg message can be seen as a number. It's the number of the segment "message" is in (The data-segment) We have to know this number, so we can load the DS register with it. Else we can't get to the bit-string in memory. We need to know WHERE the bit-string is located in memory. The number is loaded in the AX register. MOV always moves data to the operand left of the comma and from the operand right of the comma.
mov ds,ax : The MOV instruction again. Here it moves the number in the AX register (the number of the data segment) into the DS register. We have to load this DS register this way (with two instructions) Just typing: "mov ds,segment message" isn't possible.
mov ah, 09 : MOV again. This time it load the AH register with the constant value nine.
lea dx, message : LEA Load Efective Address. This intructions stores the offset within the datasegment of the bit-string message into the DX register. This offset is the second thing we need to know, when we want to know where "message" is in the memory. So now we have DS:DX. See the segment explanation above.
int 21h : This instruction causes an Interrupt. The processor calls a routine somewhere in memory. 21h tells the processor what kind of routine, in this case a DOS routine. INT's are very important and I'll explain more of them later, since they're also very, very complex. However, for now assume that it just calls a procedure from DOS. The procedure looks at the AH register to find out out what it has to do. In this example the value 9 in the AH register indicates that the procedure should write a bit-string to the screen.
mov ax, 4c00h : Load the Ax register with the constant value 4c00h
int 21h : The same INT again. But this time the AH register contains the value 4ch (AX=4c00h) and to the DOS procedure that means "exit program". The value of AL is used as an "exit-code" 00h means "No error"
That's it!!! You now fully understand this program (I hope)

[Back] [Index]

Go to DOS and type "debug first.exe". The debug screen will appear. When you are in the debugger, type "d". You see some addresses and our program.
Now type "u" you'll see a list that looks like this:
0F77:0000  B8790F          MOV AX,0F79
0F77:0003  8ED8            MOV DS,AX
0F77:0005  B409            MOV AH,09
First 0F77:0000 is the segment number and offset. B8790F is the machine code of the mov ax,0f79 instruction. B8 means "mov ax," and 790F is the number. (reversed order) Note that the instruction was: mov ax,seg message and the assembler made it mov ax,0f79 (number might be different at your computer) So that means our data is stored in the segment with the number 0F79. The other instruction lea dx,message turned into mov dx,0. So that means that the offset of the bit-string is 0 --> 0F79:0000. Let's look at that address. Type "d 0f79:0000" and YES our data is there! Look at the right of the screen and you can see the message.
Now let's calculate another address for the data. 0F79:0000 substract 2 from the segment number. That would give you 0F77 (the code segment). 0002:0000 --> 2*16+0=32. Two segments further means 32 bytes further, and that means an offset of 32.
Diagram So at this location the data is: 0F77:0020. Check by typing "d 0f77:0020". Please note that it's the SAME data. We can see it at multiple addresses only because the segments overlap! But in the program we said the data had to be in a data-segment. Remember, the .data instruction? Well, it IS in a data-segment, the data is just stored directly behind the code, but that doesn't matter. I mean, we can address the data with a segment number and an offset of zero.
Also note, that after the int 21h instruction to end the program the data doesn't immediately start, first there some undefined bytes. (probably zero) That's because segments start at paragraph boundaries. The data-segment couldn't start at 0F77:0010 anymore, because there is code there, if there wasn't any code there, the data-segment would have been: 0F78. So the data-segment has to be 0F79 (closest match) and so, some bytes after the code and before the data just take up space. But that doesn't matter. Please remember that the assembler doesn't care how the segment are in the .ASM file. In this example we first declared the data-segment, but the assembler puts it last in memory.

[Back] [Index]

The Stack

The stack is a place where data is temporarily stored. The SS and SP registers point to that place like this: SS:SP So the SS register is the segment and the SP register contains the offset. There are a few instructions that make use of the stack. POP and PUSH are the most basic ones. PUSH can "push" a value on the stack and POP can retrieve that value from the stack. It works like this:

 MOV   AX,1234H
 PUSH  AX
 MOV   AH,09
 INT   21H
 POP   AX
The final value of AX will be 1234h. First we load 1234h into AX, then we push that value to the stack. We now store 9 in AH, so AX will be 0934h and execute an INT. Then we pop the AX register. We retreive the pushed value from the stack. So AX contains 1234h again. Another example:

 MOV   AX, 1234H
 MOV   BX, 5678H
 PUSH  AX
 POP   BX
The final values will be: AX=1234h BX=1234h. We pushed the AX to the stack and we popped that value in BX.
As in the first program, you have to define a stack segment. It is easy done by the instruction .stack that will create a stack of 1024 bytes. Yes, there's more about the stack than just this. The stack usses a LIFO system (Last In First Out) Another example:
MOV   AX,1234H
 MOV   BX,5678H
 PUSH  AX
 PUSH  BX
 POP   AX
 POP   BX
The values: AX=5678h BX=1234h First the value 1234h was pushed after that the value 5678h was pushed to the stack. Acording to LIFO 5678h comes of first, so AX will pop that value and BX will pop the next.
How does the stack look in memory? Well, it "grows" downwards in memory. When you push a word (2 bytes) for example, the word will be stored at SS:SP and SP will be decreased to times. So in the beginning SP points to the top of the stack and (if you don't pay attention) it can grow so big downwards in memory that it overwrites the source code. Major system crash is the result.
[Back] [Index]

Names

There are some names you need to know. Well, you don't HAVE to know them, but it's handy if you do. I'll use these names from now on, so better learn them.
Indentifiers An identifier is a name you aply to items in your program. the two types of indetifiers are "name", wich refers to the address of a data item, and "label", wich refers to the address of an instruction. The same rules aply to names and labels.
Statements A program is made of a set of statements, there are two types of statements, "instructions" such as MOV and LEA, and "directives" wich tell the assembler to perform a specific action, like ".model small"
Here's the general format of a statement:
indentifier - operation - operand(s) - comment
The identifier is the name as explained above.
The operation is an instruction like MOV.
The operands provide information for the Operation to act on. Like MOV (operation) AX,BX (operands).
The comment is a line of text you can add as a comment, everything the assembler sees after a ";" is ignored.
So a complete instruction looks like this:
MOVINSTRUCTION:      MOV   AX,BX           ;this is a MOV instruction

The label and the comment are optional. In fact I allready explained directives , but, okay, I'll do it again. Directives provide the assembler with information on how to assemble a .ASM file. .MODEL SMALL, or .CODE are, for example, directives.

[Back] [Index]

And so we have come to the end of Section 1 of this tutorial. If you fully understand this stuff (registers, flags, segments, stack, names, etc.) you may, from now on, call yourself a "Level 0 Assembly Coder". Congratulations!
In Part 2 I'll explain some more instructions and I'll explain how to address data yourself.
(MOV BYTE PTR ES:[DI],AL)
I'll also explain the Interrupts and interrupt table.

[Back] [Index] [Next Section]

Copyright 1996, Ferdi Smit. All rights reserved.
Design & Concept by UZillusion
Text by MAD
Send any comments and sugestions to UZTeam

Friday, January 15, 2010

Same book - Donis Marshall - Linq usage

using System;

namespace Example
    {

    class Person
        {
        public Person(string _name, int _age)
            {
            name = _name;
            age = _age;
            }
        public string name = "";
        public int age = 0;
        }
    class Startup
        {
        static void Main()
            {
            Person[] people = {new Person("John", 35),
                                new Person("Jill", 24),
                                new Person("Sarah", 29),
                                new Person("Mary", 28)};
            foreach (Person p in people)
                {
                if (p.age >= 30)
                    {
                    Console.WriteLine(p.name);
                    Console.WriteLine("Press any key to continue. . .");
                    Console.ReadKey();
                    }
                }
            }
        }
    }

Little Exercises from a Book - Programming Microsoft Visual C# 2008: The Language

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HelloNamespace
    {  

    class Greetings
        {
        public static void DisplayEnglish()
            {
            Console.WriteLine("Hello, world!");
            }
        public static void DisplayItalian()
            {
            Console.WriteLine("Ciao, mondo!");
            }
        public static void DisplaySpanish()
            {
            Console.WriteLine("Hola, imundo!");
            }
        }
  

delegate void delGreeting();

class HelloWorld
        {
        static void Main(string[] args) {
            try {
                int iChoice = int.Parse(args[0]);
                delGreeting [] arrayofGreetings={
                    new delGreeting(Greetings.DisplayEnglish),
                    new delGreeting(Greetings.DisplayItalian),
                    new delGreeting(Greetings.DisplaySpanish)};
                  
                arrayofGreetings[iChoice - 1]();
            }
            catch(Exception ex) {
                Console.WriteLine(ex.Message);
                Console.WriteLine("Press any key to continue. . .");
                Console.ReadKey();
            }
        }
    }
}

JG Services - http://inflectionpivot.blogspot.com

JG Services Blog

Wednesday, January 13, 2010

Facebook - Algorithms

I suspect that when one blocks one of their friends on Facebook, Facebook systematically reorders the friends who appear in one's profile in one's 'Friends' pane.  I'm sure there is a purpose for it that has nothing to do with showing people who has been looking at their profile, but that appears to be a byproduct of their algorithm.

I suspect that immediately after blocking someone who is a 'friend' on Facebook, the friends who appear in the 'Friends' pane are people who've been looking at one's profile.

Monday, January 4, 2010

Object-Oriented Programming of End-User Applications to Enter and Query Databases - SQL Server

Relational data appears as a collection of two-dimensional tables ( relations or flat files), where common columns relate tables to each other. To use LINQ to SQL effectively, you must have some familiarity with the underlying principles of relational databases.

In LINQ to SQL, the data model of a relational database is mapped to an object model expressed in the programming language of the developer

Saturday, January 2, 2010

This is a Windows Forms Application Written in C# to Access an SQL Server Database







I Try to Be a Good Son - This is a Windows Forms Application Written in C# to Access an SQL Server Database That I Produced to Help Out My Parents' Business - All Ear Doctors Hearing Aids - Orange County, California