2 Replies - 779 Views - Last Post: 20 August 2009 - 10:50 PM Rate Topic: -----

#1 pudge1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 18-August 09

Basic VB Functions

Posted 19 August 2009 - 09:45 AM

Hey I have a couple simple VB Code Lines. Can you tell me what they do I need to convert them into a different language and to do that I need to know what they do/mean. Ignore the context because I already changed part of it to the new language.

Code1:
Open Left($FileName, Len($FileName) - 4) & ".wnc" For Binary As #1
	$FileData = Input(LOF(1), #1)
	$Return = $FileData
	Close #1
	Debug.Print Len($Return), Len($FileData)

	Open Left($FileName, Len($FileName) - 4) & "2" & Right($FileName, 4) For Output As #1
	Print #1, $Return;
	Close #1


In that one I alrady know what Left, Right and Len mean.


Code 2:
Option Explicit
Private Const $FileName = "c:\compressthis.exe"


Just need to know what these lines do.


Code 3:
For $DataPos = 1 To $ControlCount  


What that one line does


Code 4:
 $DataCount = Asc(Mid($DecompData, 5, 1)) * &H1000000 + Asc(Mid($DecompData, 6, 1)) * &H10000 + Asc(Mid($DecompData, 7, 1)) * &H100 + Asc(Mid($DecompData, 8, 1)) + 9;


And what the &H100 etc. Things do here


Code 5:
if (2 ^ $ControlBitPos = (Asc(Mid($DecompData, $ControlPos, 1)) And 2 ^ $ControlBitPos)) 


What does the and mean in this situation?

Thank you I would be willing to pay if someone helped me with all four of these.

This post has been edited by pudge1: 19 August 2009 - 10:07 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Basic VB Functions

#2 fusebyte  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 02-August 09

Re: Basic VB Functions

Posted 19 August 2009 - 04:14 PM

I think in VB6 character $ for string before a var is wrong.

For $DataPos = 1 To $ControlCount

become

Dim datapos as string
Dim ControlCount ad string

For DataPos = 1 to ControlCount
what u want.---

next ' close the cicle For

Byez
Was This Post Helpful? 0
  • +
  • -

#3 vb5prgrmr  Icon User is offline

  • D.I.C Lover

Reputation: 109
  • View blog
  • Posts: 1,016
  • Joined: 21-March 09

Re: Basic VB Functions

Posted 20 August 2009 - 10:50 PM

View Postpudge1, on 19 Aug, 2009 - 08:45 AM, said:

Hey I have a couple simple VB Code Lines. Can you tell me what they do I need to convert them into a different language and to do that I need to know what they do/mean. Ignore the context because I already changed part of it to the new language.

Code1:
Open Left($FileName, Len($FileName) - 4) & ".wnc" For Binary As #1
	$FileData = Input(LOF(1), #1)
	$Return = $FileData
	Close #1
	Debug.Print Len($Return), Len($FileData)

	Open Left($FileName, Len($FileName) - 4) & "2" & Right($FileName, 4) For Output As #1
	Print #1, $Return;
	Close #1


In that one I alrady know what Left, Right and Len mean.

Open line used for opening file (vb intrinsic) Binary = access method (binary append output input read write) As #File number
$=string, FileData=variable name, Input=read x number of bytes from file, LOF=length of file, #1=file number
Next line is passing the contents of the file from one variable to another
Close #1 = close file
Debug.Print = used for debugging purposes don't know which language you are using so don't know how to tell you how to convert.

NOTE:The purpose of the above code is to copy a file which in vb can be accomplished with the FileCopy command
ALSO:$Filename is not a valid variable name and will raise error (Invalid Character). However, FileName$ is the correct syntax. So wherever you got this code from, you had better check your source...

View Postpudge1, on 19 Aug, 2009 - 08:45 AM, said:

Code 2:
Option Explicit
Private Const $FileName = "c:\compressthis.exe"


Just need to know what these lines do.

Private=scope of variable, const=constant(does not change),$FileName=(see above)

View Postpudge1, on 19 Aug, 2009 - 08:45 AM, said:

Code 3:
For $DataPos = 1 To $ControlCount  


What that one line does

This is the basic structure of a for loop. However this code will not run as once again these are supposed to be strings and a for loop unumerates through numbers

View Postpudge1, on 19 Aug, 2009 - 08:45 AM, said:

Code 4:
 $DataCount = Asc(Mid($DecompData, 5, 1)) * &H1000000 + Asc(Mid($DecompData, 6, 1)) * &H10000 + Asc(Mid($DecompData, 7, 1)) * &H100 + Asc(Mid($DecompData, 8, 1)) + 9;


And what the &H100 etc. Things do here

Asc=returns character code for a single character,Mid(String, position, number of characters)=in above example it is supposed to return one character at position 5 from the string
&H=hex code
As for what it is supposed to do...

View Postpudge1, on 19 Aug, 2009 - 08:45 AM, said:

Code 5:
if (2 ^ $ControlBitPos = (Asc(Mid($DecompData, $ControlPos, 1)) And 2 ^ $ControlBitPos)) 


What does the and mean in this situation?

Thank you I would be willing to pay if someone helped me with all four of these.

^=used to raise a number to the power of an exponent


It really looks like you are going to need a lot of conversion between what you have and where you are going with it so try these sites...

http://www.rentacoder.com
http://www.guru.com
http://www.odesk.com



Good Luck
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1