C procedure to Vb.Net

bobbynad

Member
Joined
Jun 28, 2003
Messages
20
Location
India
vtputs (Char * f)
{
char cbuf[1024];

strcpy(cbuf,f);
strcat(cbuf,"\n");
vtProcessedTextOut(cbuf, strlen(cbuf));

return(0);
}


Please , How would be the above code written in VB.Net.
 
Ill tell you what that c code is supposed to do. I dont know vb.net, maybe someone else can help, sorry.

vtpus = a method that takes a cstring named f and returns an int.

1) A cstring named cbuf that can hold 1024 characters is made.
2) Copy the characters in f to cbuf
3) Invoke vtProcessedTextOut(). Parameter 1 is the string you want to use, and parameter 2 is the length of the string you want to use.
4) return 0

Just so you know, that code u posted wont compile and if f is more than 1024 bytes, youll get a buffer overflow.

for .net, you would make a method, vtputs, that returns an Int32 and takes a String named f.

line1 = vtProcessedTextOut(f, f.Length)
line2 = return 0
 
This should do the same thing, I dont know what vtProcessedTextOut is though, Im treating it as a second procedure.
Code:
The command ByVal creates a COPY of the original, ByRef gets an actual reference
Public Sub vtPuts(ByVal f() As Char)
vtProcessedTextOut(f, f.GetUpperBound(0))
End Sub
 
Back
Top