Jump to content
  • Advertisement
Sign in to follow this  
kappa

[.net] Passing parameters to a dll written in C# from vb script?

This topic is 4514 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I wrote a dll in C# looking like this:
public void Start()
		{
			m_tkWriter = new Toolkit();
			m_tkWriter.OpenOutputFile( "c://test_pdf//test.pdf" );
		}

		public void End()
		{
			
			m_tkWriter.CloseOutputFile();
			m_tkWriter = null;
		}
		
		public void PrintTextBlock( string font, float fontsize, float length, float width, string text, short justification )
		{			
			y_current -= m_tkWriter.HeightPrinted;
			m_tkWriter.PrintMultilineText( font, fontsize, (x_current+LeftMargin), y_current-fontsize, A4X-(RightMargin+LeftMargin), (A4Y-(TopMargin+BottomMargin)), text, justification );
			
			while( m_tkWriter.ClipText != "" )
			{
				y_current = A4Y;
				m_tkWriter.NewPage();	
				m_tkWriter.PrintMultilineText( font, fontsize, (x_current+LeftMargin), (y_current-TopMargin)-(fontsize), A4X-(RightMargin+LeftMargin), (A4Y-(TopMargin)), m_tkWriter.ClipText, justification );
				
				if( m_tkWriter.ClipText == "" )
					y_current -= TopMargin;
			}
		}


and I am using it (or should be using it) in a regular asp website, like this:
PDF.Start
PDF.PrintTextBlock CStr(vcharFontNameText), CDbl(intFontSizeText), 500.0, 500.0, CStr(vcharQuestion2), 0  
PDF.End

PDF.Start runs ok, so it can't be that it does not find the dll, but the PrintTextBlock function gives me an error that reads roughly translated to invalid procedure or method. Where am I doing wrong?

Share this post


Link to post
Share on other sites
Advertisement
PDF.PrintTextBlock CStr(vcharFontNameText), CDbl(intFontSizeText), 500.0, 500.0, CStr(vcharQuestion2), 0

From the days of my VB6 coding time (hell, 5 years ago), I remember that in VB there are two types of calls, Subs and Functions. Subs have no parameters and no return type, they are like "void func(void)" methods from C#. You can call a sub without using the parameter list parentheses. However, if you want parameters you write a Function in VB, which requires a special syntax for calling.

IIRC, it would be

PDF.PrintTextBlock(CStr(vcharFontNameText, CDbl(intFontSizeText), 500.0, 500.0, CStr(vcharQuestion2), 0)

edit:
Forgot, the call keyword is if you want to call a sub with a (empty) parameter list.

Share this post


Link to post
Share on other sites
To be more exact: the only difference between Sub and Function is that a Sub does not return anything whereas a Function will.

The Call keyword allows you to call a Function (or Sub) while specifying the brackets.

VB6 has some bad things going on regarding these brackets. Consider this:

Sub Foo(ByRef bar As Integer)
bar = bar + 1
End Sub

Sub Main()
Dim i As Integer
i = 5
Foo i
Foo(i)
Call Foo(i)
Call Foo((i))
End Sub


All four calls are valid but the results might differ.

The first one works as expected i changes.
The second one does NOT change i because the parameter is not i but (i). (i) is evaluated to a value and Foo will be called with a ByVal parameter
The thrid is equal to the first.
The last one has the same efect as the second!!! The outer brackets are related to the Call keyword but the inner have the same effect as the brackets in the second call.

Long live VB.NET! (Compared to VB6)

Cheers

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!