Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert.ToInt32(lpszName)

Status
Not open for further replies.

andyburrow

Programmer
Joined
Apr 15, 2005
Messages
14
Location
GB
Hey Guys,

I need some help on the 'Dim lpszName As Char (100)' line and the 'MyNumber = Convert.ToInt32(lpszName)' line.

It comes up saying MyNumber not defined; fine, so I Dim MyNumber, say as an Integer or a Char, and then it says 'Value is not a member of...'; on the CapGetDriver line.

Can someone help? I'm pulling my hair out here.

I've copied in the entire Sub at the bottom.

Cheers
Andy

Sub MapWebcamToWindow(ByRef lWidth As Integer, ByRef lHeight As Integer, ByRef hWnd As Integer)

>>> Dim lpszName As Char(100)
>>> MyNumber = Convert.ToInt32(lpszName)

Dim bmp As BITMAPINFO
With bmp.bmiHeader
.biSize = Len(bmp.bmiHeader)
.biWidth = 320
.biHeight = 240
.biPlanes = 1
.biBitCount = 24
End With
>>> capGetDriverDescriptionA(0, MyNumber.Value, 100, Nothing, 100)
lwndC = capCreateCaptureWindowA(MyNumber.Value, _
WS_VISIBLE Or WS_CHILD, 0, 0, lWidth, lHeight, hWnd, 0)
If capDriverConnect(lwndC, 0) Then
capPreviewRate(lwndC, 66)
capPreview(lwndC, True)
capSetVideoFormat(lwndC, bmp, Len(bmp))
SetWindowPos(lwndC, 0, 0, 0, bmp.bmiHeader.biWidth, _
bmp.bmiHeader.biHeight, SWP_NOMOVE Or SWP_NOZORDER)
End If
End Sub

Sub CloseWebcam()
capDriverDisconnect(lwndC)
End Sub

End Module
 
Code:
Dim lpszName As Char(100)
MyNumber = Convert.ToInt32(lpszName)

I'm assuming some code is missing here, becuase you are trying to convert an empty character array into an integer.

Also, if lpszName is a 100 digit long number, I don't think a 32b Integer is going to hold it.

-Rick

----------------------
[banghead]If you're about to post an ASP.Net question,
please don't do it in the VB.Net forum[banghead]

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
Hey Rick - This is where my VB.NET skills lack; hoping for some assistance.

The only other reference to 'lpszName' is in the following Function Declaration above the Sub that I pasted in to this thread..

"Declare Function capGetDriverDescriptionA Lib "avicap32.dll" (ByVal wDriver As Short, ByVal lpszName As String, ByVal cbName As Integer, ByVal lpszVer As String, ByVal cbVer As Integer) As Boolean"

The original code was as follows:

"Sub MapWebcamToWindow(ByRef lWidth As Integer, ByRef lHeight As Integer, ByRef hWnd As Integer)
Dim lpszName As New VB6.FixedLengthString(100)
Dim bmp As BITMAPINFO
With bmp.bmiHeader
.biSize = Len(bmp.bmiHeader)
.biWidth = 320
.biHeight = 240
.biPlanes = 1
.biBitCount = 24........."

However the .NET framework didn't like the VB6.FixedLengthString(100) statement, so I am having to re-write it in to .NET, if you see what I mean..
 
Sorry, the full original sub is:

"Sub MapWebcamToWindow(ByRef lWidth As Integer, ByRef lHeight As Integer, ByRef hWnd As Integer)
Dim lpszName As New VB6.FixedLengthString(100)
Dim bmp As BITMAPINFO
With bmp.bmiHeader
.biSize = Len(bmp.bmiHeader)
.biWidth = 320
.biHeight = 240
.biPlanes = 1
.biBitCount = 24
End With
capGetDriverDescriptionA(0, lpszName.Value, 100, Nothing, 100)
lwndC = capCreateCaptureWindowA(lpszName.Value, _
WS_VISIBLE Or WS_CHILD, 0, 0, lWidth, lHeight, hWnd, 0)
If capDriverConnect(lwndC, 0) Then
capPreviewRate(lwndC, 66)
capPreview(lwndC, True)
capSetVideoFormat(lwndC, bmp, Len(bmp))
SetWindowPos(lwndC, 0, 0, 0, bmp.bmiHeader.biWidth, _
bmp.bmiHeader.biHeight, SWP_NOMOVE Or SWP_NOZORDER)
End If
End Sub

Sub CloseWebcam()
capDriverDisconnect(lwndC)
End Sub

End Module
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top