Pues yo no entiendo no papa XD
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes MenúDo
hHwnd = capCreateCaptureWindowA(strDevice, WS_VISIBLE Or WS_CHILD, 0, 0, 640, 480, Picture1.hwnd, 0)
DoEvents
Loop While hwnd = 0
'//...
Private Sub Espera(Segundos As Single)
Dim ComienzoSeg As Single
Dim FinSeg As Single
ComienzoSeg = Timer
FinSeg = ComienzoSeg + Segundos
Do While FinSeg > Timer
DoEvents
If ComienzoSeg > Timer Then
FinSeg = FinSeg - 24 * 60 * 60
End If
Loop
End Sub
'//Conecta la cámara
Private Sub ConectarCamara()
'//Activa la webcam
hHwnd = capCreateCaptureWindowA(strDevice, WS_VISIBLE Or WS_CHILD, 0, 0, 640, 480, Picture1.hWnd, 0)
Espera (2) '///<---Esperar dos segundos antes de conectar
Dim Retry As Boolean, I As Integer
For I = 1 To 10 '//Hace diez intentos para conectar
Retry = SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, IndexDevice, 0)
If Retry = True Then
SendMessage hHwnd, WM_CAP_SET_SCALE, False, 0
SendMessage hHwnd, WM_CAP_SET_PREVIEWRATE, 66, 0
SendMessage hHwnd, WM_CAP_SET_PREVIEW, True, 0
SetWindowPos hHwnd, HWND_BOTTOM, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, _
SWP_NOMOVE Or SWP_NOZORDER
cmdGuardar.Enabled = True
cmdDesconectar.Enabled = True
cmdConectar.Enabled = False
Exit For
End If
Next I
If Retry = False Then
DestroyWindow hHwnd
cmdGuardar.Enabled = False
End If
End Sub
'//...
...
2
down vote
Finally I Found a solution for this.
The problem happens in Windows 7 / 8
First you need this API function
Private Declare Function GetTickCount Lib "kernel32" () As Long
Then... after you call capCreateCaptureWindowA() you have to wait 1 second processing events, (note: sleep don't work the same)
IniTime = GetTickCount()
While GetTickCount() < (IniTime + 1000)
DoEvents
Wend
then you call WM_CAP_DRIVER_CONNECT (maybe a couple of times).. and THAT's IT ... no more video source dialog
'...
With this solution it works perfect. The GetTickCount() waiting for events worked along with calling the function until it returned true.
Private Sub PreviewVideo(ByVal pbCtrl As PictureBox)
hWnd = capCreateCaptureWindowA(VideoSource, WS_VISIBLE Or WS_CHILD, 0, 0, 0,
0, pbCtrl.Handle.ToInt64, 0)
Dim IniTime As Long = GetTickCount()
While GetTickCount() < (IniTime + 1000)
Application.DoEvents()
End While
Dim OKAnswer As Boolean = False
For xretries As Integer = 1 To 10
' I'll give you Only 10 tries to connect, otherwise I AM LEAVING MICROSOFT!
OKAnswer = SendMessage(hWnd, WM_CAP_DRIVER_CONNECT, VideoSource, 0)
If OKAnswer Then
Exit For
End If
Next
If okanswer Then
SendMessage(hWnd, WM_CAP_SET_SCALE, True, 0)
SendMessage(hWnd, WM_CAP_SET_PREVIEWRATE, 30, 0)
SendMessage(hWnd, WM_CAP_SET_PREVIEW, True, 0)
SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, pbCtrl.Width, pbCtrl.Height, SWP_NOMOVE Or SWP_NOZORDER)
Else
DestroyWindow(hWnd)
End If
End Sub
Dim intCol As New List(Of Integer)({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}.OfType(Of Integer))
Dim pairsCol As IEnumerable(Of String) = Nothing
pairsCol =
From value1 As Integer In intCol
From value2 As Integer In intCol
From value3 As Integer In intCol
From value4 As Integer In intCol
From value5 As Integer In intCol
Select String.Join(Environment.NewLine, (
From value6 As Integer In intCol
Where (value1 <> value2) AndAlso
(value1 <> value3) AndAlso
(value1 <> value4) AndAlso
(value1 <> value5) AndAlso
(value1 <> value6) AndAlso
(value2 <> value3) AndAlso
(value2 <> value4) AndAlso
(value2 <> value5) AndAlso
(value2 <> value6) AndAlso
(value3 <> value4) AndAlso
(value3 <> value5) AndAlso
(value3 <> value6) AndAlso
(value4 <> value5) AndAlso
(value4 <> value6) AndAlso
(value5 <> value6) AndAlso
(value2 > value1) AndAlso
(value3 > value2) AndAlso
(value4 > value3) AndAlso
(value5 > value4) AndAlso
(value6 > value5)
Select String.Format("{0:00} {1:00} {2:00} {3:00} {4:00} {5:00}",
value1, value2, value3, value4, value5, value6)))
For Each pairs As String In pairsCol
For Each line As String In pairs.Split({Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)
ListBox1.Items.Add(line)
Next line
Next pairs
Dim intCol As New List(Of Integer)({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}.OfType(Of Integer))
Dim pairsCol As IEnumerable(Of String) = Nothing
pairsCol =
From value1 As Integer In intCol
From value2 As Integer In intCol
From value3 As Integer In intCol
From value4 As Integer In intCol
From value5 As Integer In intCol
Select String.Join(Environment.NewLine, (
From value6 As Integer In intCol
Where (value1 <> value2) AndAlso
(value1 <> value3) AndAlso
(value1 <> value4) AndAlso
(value1 <> value5) AndAlso
(value1 <> value6) AndAlso
(value2 <> value3) AndAlso
(value2 <> value4) AndAlso
(value2 <> value5) AndAlso
(value2 <> value6) AndAlso
(value3 <> value4) AndAlso
(value3 <> value5) AndAlso
(value3 <> value6) AndAlso
(value4 <> value5) AndAlso
(value4 <> value6) AndAlso
(value5 <> value6) AndAlso
(value2 > value1) AndAlso
(value3 > value2) AndAlso
(value4 > value3) AndAlso
(value5 > value4) AndAlso
(value6 > value5)
Select String.Format("{0:00} {1:00} {2:00} {3:00} {4:00} {5:00}",
value1, value2, value3, value4, value5, value6)))
For Each pairs As String In pairsCol
For Each line As String In pairs.Split({Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)
Dim Pattern As String = " "
Dim Digito() As String
Digito = System.Text.RegularExpressions.Regex.Split(line, Pattern)
If CInt(Digito(1)) <> CInt(Digito(0)) + 1 Or
CInt(Digito(2)) <> CInt(Digito(1)) + 1 Or
CInt(Digito(3)) <> CInt(Digito(2)) + 1 Or
CInt(Digito(4)) <> CInt(Digito(3)) + 1 Or
CInt(Digito(5)) <> CInt(Digito(4)) + 1 Then
ListBox1.Items.Add(line)
End If
Next line
Next pairs
Dim intCol As New List(Of Integer)({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}.OfType(Of Integer))
Dim pairsCol As IEnumerable(Of String) = Nothing
pairsCol =
From value1 As Integer In intCol
From value2 As Integer In intCol
From value3 As Integer In intCol
From value4 As Integer In intCol
From value5 As Integer In intCol
Select String.Join(Environment.NewLine, (
From value6 As Integer In intCol
Where (value1 <> value2) AndAlso
(value1 <> value3) AndAlso
(value1 <> value4) AndAlso
(value1 <> value5) AndAlso
(value1 <> value6) AndAlso
(value2 <> value3) AndAlso
(value2 <> value4) AndAlso
(value2 <> value5) AndAlso
(value2 <> value6) AndAlso
(value3 <> value4) AndAlso
(value3 <> value5) AndAlso
(value3 <> value6) AndAlso
(value4 <> value5) AndAlso
(value4 <> value6) AndAlso
(value5 <> value6) AndAlso
(value2 > value1) AndAlso
(value3 > value2) AndAlso
(value4 > value3) AndAlso
(value5 > value4) AndAlso
(value6 > value5)
Select String.Format("{0:00} {1:00} {2:00} {3:00} {4:00} {5:00}",
value1, value2, value3, value4, value5, value6)))
For Each pairs As String In pairsCol
For Each line As String In pairs.Split({Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)
Dim Pattern As String = " "
Dim Digito() As String
Digito = System.Text.RegularExpressions.Regex.Split(line, Pattern)
If CInt(Digito(1)) <> CInt(Digito(0)) + 1 Or
CInt(Digito(2)) <> CInt(Digito(1)) + 1 Or
CInt(Digito(3)) <> CInt(Digito(2)) + 1 Or
CInt(Digito(4)) <> CInt(Digito(3)) + 1 Or
CInt(Digito(5)) <> CInt(Digito(4)) + 1 Then
ListBox1.Items.Add(line)
End If
Next line
Next pairs
'//Esto solo crea un array con la última combinación.
'//En realidad lo hace con todas pero solo queda registrada la última
'//¿Habría que hacer una colección de arrays?
Dim NuevaLista As New List(Of String)(ListBox1.Items.OfType(Of String))
Dim int32Col As IEnumerable(Of Integer) = Nothing
For Each item As String In NuevaLista
int32Col = From Elemento As String In item.Split(" "c) Select CInt(Elemento)
Next
'Los números de la última combinación
MessageBox.Show(int32Col(0).ToString)
MessageBox.Show(int32Col(1).ToString)
MessageBox.Show(int32Col(2).ToString)
MessageBox.Show(int32Col(3).ToString)
MessageBox.Show(int32Col(4).ToString)
MessageBox.Show(int32Col(5).ToString)
(value5 <> value6) AndAlso
Dim builder As New System.Text.StringBuilder
With builder
.AppendLine("<table border=""1"" style=""border-collapse: collapse;"">")
.AppendLine("<caption>Leyenda</caption>")
.AppendLine("<tbody>")
.AppendLine("<tr>")
.AppendLine(String.Format("<td>{0}</td>", "Celda1"))
.AppendLine(String.Format("<td>{0}</td>", "Celda2"))
.AppendLine("</tr>")
.AppendLine("<tr>")
.AppendLine(String.Format("<td>{0}</td>", "Celda3"))
.AppendLine(String.Format("<td>{0}</td>", "Celda4"))
.AppendLine("</tr>")
.AppendLine("</tbody>")
.AppendLine("</table>")
End With
Imports System.Web.UI.HtmlControls
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As Integer
Dim j As Integer
Dim Table1 As HtmlTable
Dim row As HtmlTableRow
Dim cell As HtmlTableCell
'//...
End Sub
End Class
ListBox1.Items.Add("01 02 03 04 05 06")
ListBox1.Items.Add("10 20 30 44 45 46")
ListBox1.Items.Add("12 22 34 45 56 65")
ListBox1.Items.Add("12 22 34 45 56 65")
Dim Pattern As String = " "
Dim Digito() As String
'//Mete los Items del ListBox en ClearList
Dim ClearList As New List(Of String)(ListBox1.Items.OfType(Of String))
For Each Item As String In ClearList
Digito = System.Text.RegularExpressions.Regex.Split(Item, Pattern)
If CInt(Digito(1)) = CInt(Digito(0)) + 1 And
CInt(Digito(2)) = CInt(Digito(1)) + 1 And
CInt(Digito(3)) = CInt(Digito(2)) + 1 And
CInt(Digito(4)) = CInt(Digito(3)) + 1 And
CInt(Digito(5)) = CInt(Digito(4)) + 1 Then
ListBox1.Items.Remove(Item) '<-----Borra un Item del ListBox
End If
Next
ClearList.Clear() '//Borra ClearList
ClearList.AddRange(ListBox1.Items.OfType(Of String)) '//Consigue la nueva lista del ListBox
Dim NuevaLista As New List(Of Double)
For Each Item As String In ClearList
NuevaLista.Add(Item.Replace(" ", Nothing))
Next
MessageBox.Show(NuevaLista(0).ToString)
MessageBox.Show(NuevaLista(1).ToString)
Dim Cadena as string = "12345"
Dim Numero as Integer = Cadena
Dim Cadena As String = "-12345"
Dim Numero As Integer = Cadena
no se puede pasar el codigo entero a integer ?
Dim txtCadena as String = "La patata boba"
Cita de: fary en 6 Abril 2016, 22:04 PM
Jajajaja, en VB6 o en cualquier otro lenguaje se usan las mismas funciones... Pero vamos que si insistes y tienes mucho interés lo programo.
Saludos.
Dim ClearList As New List(Of String)(ListBox1.Items.OfType(Of String))
Dim NuevaLista As New List(Of String)(ListBox1.Items.OfType(Of String))
ListBox1.Items.Add("01 02 03 04 05 06")
ListBox1.Items.Add("10 20 30 44 45 46")
ListBox1.Items.Add("12 22 34 45 56 65")
ListBox1.Items.Add("12 22 34 45 56 65")
Dim Pattern As String = " "
Dim Digito() As String
'//Mete los Items del ListBox en ClearList
Dim ClearList As New List(Of String)(ListBox1.Items.OfType(Of String))
For Each Item As String In ClearList
Digito = System.Text.RegularExpressions.Regex.Split(Item, Pattern)
If CInt(Digito(1)) = CInt(Digito(0)) + 1 And
CInt(Digito(2)) = CInt(Digito(1)) + 1 And
CInt(Digito(3)) = CInt(Digito(2)) + 1 And
CInt(Digito(4)) = CInt(Digito(3)) + 1 And
CInt(Digito(5)) = CInt(Digito(4)) + 1 Then
ListBox1.Items.Remove(Item) '<-----Borra un Item del ListBox
End If
Next
'//Mete la nueva lista en NewList
Dim NuevaLista As New List(Of String)(ListBox1.Items.OfType(Of String))
NuevaLista = NuevaLista.Distinct.ToList '//Quita Items repetidos
MessageBox.Show(NuevaLista(0).ToString)
MessageBox.Show(NuevaLista(1).ToString)
CInt(Digito(5)) = CInt(Digito(4)) + 1
CInt(Digito(4)) = CInt(Digito(3)) + 1