Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Help calling sub procedures in html.
Old 12-02-2004, 12:35 AM Help calling sub procedures in html.
Webmaster Talker

Posts: 626
Trades: 0
Hello,

I have a little background in VB. I am new to HTML and therefore new to incorporating VB with HTML. I seem to be getting errors when I try to put some sub procedures in my html page.

I have included my sample page. It may be VERY wrong but if anyone could help me with my syntax or point me in the direction where to look I would appreciate it.

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script language="vb">
Option Explicit
Public Function CapitalNeeded(pmt, whenbegin, yearsneeded, i, inf As Double) As Double
//********************************************************************************************************
// pmt -> income needed
// whenbegin -> years until payment begins
// yearsneeded -> how long the income would be needed
// i -> interest rate capital would be invested at
// inf -> rate to calculate for inflation
//********************************************************************************************************
    Dim t As Integer
    Dim capneeded As Double
    Dim increq As Double
        
    For t = whenbegin + 1 To yearsneeded + whenbegin
        increq = pmt * (1 + inf) ^ (yearsneeded - t)
        capneeded = capneeded + PVLumpSum(increq, yearsneeded - t, (i))
    Next t
    
    CapitalNeeded = capneeded
End Function

Public SUB showit()
	document.write(CaptialNeeded(10000,0,30,0.06,0.03))
end SUB
</script>

</head>

<body>
<table width=150 height=30 border=2 bgcolor="#C0C0C0" align="center">
<tr>
	<td align="center" onclick=showit() style="cursor:hand;">Button 1
</td>
</tr>
<tr height=33>
		<td>&nbsp;</td></tr></table>
</body>
</html>
jim.thornton is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-02-2004, 12:52 AM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
Did you rename the page with a .asp extension instead of a .html one. Also, telling us the error your getting would be very helpful.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Old 12-02-2004, 02:28 AM
Webmaster Talker

Posts: 626
Trades: 0
oops!

Yes, I guess it would be helpful. The error I'm getting is: "showit" undefined line xxx.

No I didn't rename any pages I edited the page in dreamweaver as an html page and then tried to view it in iexplorer. I was under the impression that .asp files were server-side scripts and everytime I have tried to view one of those pages on my computer (disconnected) it hasn't let me due to not having a testing server. I don't have a hosting plan yet as I am waiting to get my site ready to post.

zinc.
jim.thornton is offline
Reply With Quote
View Public Profile
 
Old 12-02-2004, 05:17 AM
Minaki's Avatar
Defies a Status

Posts: 1,626
Location: Guildford, UK
Trades: 0
You're right - .asp extention is for server side code, as you're using client side, .html is fine.

Not sure exactly where your problem is because I've never used VB as a client side language, however I'm fairly sure you don't/can't use Public and Private for functions. All in all, the I think your problem lies in the fact that you're trying to put vb -code- into vb -script-. They share the same syntax however the structure is different.

One thing you may already be aware of, if this is going to be an internet web page then you probably don't want to use VB at all, because it's only supported on Internet Explorer so you'll be cutting out a significant number of visitors. If it's an intranet page, and you know for a fact that everyone is using IE, then it's fine.
__________________
Minaki Serinde MCP
"Wow, Linux is nearly on-par with Windows ME!"

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Minaki is offline
Reply With Quote
View Public Profile Visit Minaki's homepage!
 
Old 12-02-2004, 09:45 AM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
I never knew you could use vb as a client side language.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Old 12-02-2004, 10:08 AM
Anacrusis's Avatar
Defies a Status

Posts: 2,099
Name: Adam
Location: Colchester CT
Trades: 0
Client side vb is not true Visual basic code... it's vbscript. There are some things you can't do with vbscript and as Minaki pointed out, private/public is one of them. Subs are also a no-no I believe, you can only use functions.

I don't think you can define datatypes either, everything is a varient type by default.

I could be wrong as I'm more used to server side vbscript. Somebody please correct me if I am.
Anacrusis is offline
Reply With Quote
View Public Profile
 
Old 12-02-2004, 10:03 PM
Webmaster Talker

Posts: 626
Trades: 0
Thank you very much guys... What type of scripting would you recommend for client side?

zinc.
jim.thornton is offline
Reply With Quote
View Public Profile
 
Old 12-02-2004, 10:25 PM
Rincewind's Avatar
Super Talker

Posts: 108
Trades: 0
Unfortunetly vbscript is quite limited for client side use since only IE supports it. For client side, the norm has become javascript or jscript. (jscript is MS's version of javascript). Support for javascript is almost perfect among browser clients. Though some users decide to turn it off for security fears.
__________________
Q-4.net -
Please login or register to view this content. Registration is FREE

Stylegallery.co.uk -
Please login or register to view this content. Registration is FREE

Splodgy.com -
Please login or register to view this content. Registration is FREE
Rincewind is offline
Reply With Quote
View Public Profile
 
Old 12-02-2004, 11:31 PM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
Personaly as much as I could I would steer away from client side and more towards server side. Much more secure code that is platform/browser independant.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Old 12-02-2004, 11:37 PM
Anacrusis's Avatar
Defies a Status

Posts: 2,099
Name: Adam
Location: Colchester CT
Trades: 0
As cptnwinky stated, use server side if possible. It will make your pages load faster as all the processing is done on the server, not the clients machine. Also, you won't have to worry about the users settings not working well with your code.
Anacrusis is offline
Reply With Quote
View Public Profile
 
Old 12-05-2004, 09:01 PM
Webmaster Talker

Posts: 626
Trades: 0
Could someone point me in the direction to learn how to setup server-side code and calling them. If I use ASP (VB) server-side is it still only compatible with IE?

Zinc.
jim.thornton is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Help calling sub procedures in html.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.69774 seconds with 12 queries