|
hi
i'm doing the vb project
how to record the videos and saving the videos in vb6
please send the codes
|
|
|
|
|
Firstly you don't want to be doing this in VB6 - it's an unsupported language.
Using VB.NET would be better (I'd use C# but that's just my preference).
Secondly you can't record videos in any language ... but you can interface to a camera - exactly how may depend on which camera you use.
This article does some stuff with a webcam - it's in C# but there are plenty of ways of converting into VB for free (look on Google)
Versatile WebCam C# library[^]
|
|
|
|
|
Hello guys,
I posted a question earlier and gut a reply but i dont know how to reply to them, anyway thanks Zoltan and Ron. here is my question, "i have two forms, form1 and form2. i have a button in form1 to show form 2. but when i move form1 and click the button form2 show not in the center. I want form2 always show in the center of form1 even it from another location. thanks. what i got here is this code but it gives me and error in "Me", please help
code
Dim Show_login As New form2
Show_login.StartPosition = FormStartPosition.CenterParent
Show_login.Parent = Me
Show_login.Show()
|
|
|
|
|
athan_makubex wrote: gut a reply but i dont know how to reply to them Try clicking the "Reply" link at the bottom of the message.
Use the best guess
|
|
|
|
|
|
Hi
try this way : select Form2 property and look at layout options
then StartPosition : Centerscreen (or whatelse available , centerparent..)
Regards
modified 20-May-13 2:44am.
|
|
|
|
|
Hi All,
i have an Excel which contains 25 columns.Treating it as source file,i need to generate a report which needs to display 3 columns ,also i need to evaluate some calculations and need to display in a newly created column..
Requestname,status and validity.i need to display only these columns in my report.In addition to that i need to calculate the num of requests based on the status/validity values and need to display in seperate column "number of requests".
also we need to calculate the difference between the time based on two columns(format mm/dd/yyyy hh:mm) and put in a seperate column to display.
If this is the wrong window,please suggest me the apt place to post.
|
|
|
|
|
Well, you have told us what your requirements are, but not what the problem is that you are facing. If you are expecting someone to write the code for you, you have come to the wrong place.
Use the best guess
|
|
|
|
|
Hi everybody, am going to show you a sample program which enables to print the contents of a datagridview, the program works properly despite a minor error which occurs before the printing is done it says OBJECT REFERENCE NOT SET TO AN INSTANCE OF AN OBJECT, although it does not prevent the program from meeting the purpose. i would like to share it with you, and atleast we can discus on how to remove that error.
The program is based on the customers table of the Northwind Database.
On my form there is a datagridview named Mydatagridview, A print button called btnPrint
Below is the VB code ..............
Imports System.Data.OleDb
Imports System.Drawing.Printing
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Text
Imports System.Windows.Forms
Imports System.Drawing
Public Class Form1
Private WithEvents printDocument1 As New PrintDocument
'Used to save left coordinates of columns
Dim arrColumnLefts = New ArrayList()
'Used to save column widths
Dim arrColumnWidths = New ArrayList()
'Used to get and set the datagridview cell height
Dim iCellHeight As Integer = 0
Dim iTotalWidth As Integer = 0
'Used as counter
Dim iCount As Integer = 0
Dim iRow As Integer = 0
'Used to check whether we are printing first page
Dim bFirstPage As Boolean = False
'Used to check whether we are printing a new page
Dim bNewPage As Boolean = False
'Used for the header height
Dim iHeaderHeight As Integer = 0
Dim strFormat = New StringFormat()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim con As New OleDb.OleDbConnection
con.ConnectionString = "provider=microsoft.jet.oledb.4.0; Data source= " & Application.StartupPath & "\Customers.mdb"
Dim ds As DataSet = New DataSet()
Dim dt As New DataTable
Dim da As OleDbDataAdapter = New OleDbDataAdapter("SELECT CompanyName,ContactName,Address,PostalCode,Phone from Customers2", con)
Me.WindowState = FormWindowState.Maximized
Try
da.Fill(ds, "dt")
da.Fill(ds, "Customers2")
MyDataGridView.DataSource = ds
MyDataGridView.DataMember = "dt"
Catch ex As Exception
MessageBox.Show("Operation failed: " + ex.ToString(), Application.ProductName + " - Error", MessageBoxButtons.OK, MessageBoxIcon.[Error])
Return
End Try
End Sub
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
'Open the print dialogue
Dim MyPrintDialog = New PrintDialog()
MyPrintDialog.Document = printDocument1
MyPrintDialog.UseEXDialog = True
'Get the document
If Windows.Forms.DialogResult.OK = MyPrintDialog.ShowDialog() Then
printDocument1.DocumentName = "Test page print"
printDocument1.Print()
End If
End Sub
Private Sub printDocument1_BeginPrint(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles _
printDocument1.BeginPrint
' MsgBox("starting printpage")
Try
strFormat.Alignment = StringAlignment.Near
strFormat.LineAlignment = StringAlignment.Center
strFormat.Trimming = StringTrimming.EllipsisCharacter
arrColumnLefts.Clear()
arrColumnWidths.Clear()
iCellHeight = 0
bFirstPage = True
bNewPage = True
'Calculating Total Widths
iTotalWidth = 0
For Each dgvGridCol As DataGridViewColumn In MyDataGridView.Columns
iTotalWidth = iTotalWidth + dgvGridCol.Width
Next
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub printDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles _
printDocument1.PrintPage
Try
'Set the left margin
Dim iLeftMargin As Integer = e.MarginBounds.Left
'Set the top margin
Dim iTopMargin As Integer = e.MarginBounds.Top
'Whether more pages have to print or not
Dim bMorePagesToPrint As Boolean = False
Dim iTmpWidth As Integer = 0
'For the first page to print set the cell width and header height
If bFirstPage = True Then
For Each Gridcol As DataGridViewColumn In MyDataGridView.Columns
iTmpWidth = CType(Math.Floor(CType(CType(Gridcol.Width, Double) / CType(iTotalWidth, Double) * CType(iTotalWidth, Double) * (CType(e.MarginBounds.Width, Double) / CType(iTotalWidth, Double)), Double)), Integer)
iHeaderHeight = CType((e.Graphics.MeasureString(Gridcol.HeaderText, Gridcol.InheritedStyle.Font, iTmpWidth).Height) + 11, Integer)
'Save width and height of headers
arrColumnLefts.Add(iLeftMargin)
arrColumnWidths.Add(iTmpWidth)
iLeftMargin = iLeftMargin + iTmpWidth
Next
End If
'Loop till all the grid rows not get printed
While iRow <= MyDataGridView.Rows.Count - 1
Dim GridRow As DataGridViewRow = MyDataGridView.Rows(iRow)
'Set the cell height
iCellHeight = GridRow.Height + 5
Dim iCount As Integer = 0
'Check whether the current page settings allo more rows to print
If iTopMargin + iCellHeight >= e.MarginBounds.Height + e.MarginBounds.Top Then
bNewPage = True
bFirstPage = False
bMorePagesToPrint = True
Exit While
Else
If bNewPage = True Then
'Draw header
e.Graphics.DrawString("Fibre Requirements", New Font(MyDataGridView.Font, FontStyle.Bold), Brushes.Black, e.MarginBounds.Left, e.MarginBounds.Top - e.Graphics.MeasureString("Customer Summary", New Font(MyDataGridView.Font, FontStyle.Bold), e.MarginBounds.Width).Height - 13)
Dim strDate As String = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToShortTimeString()
'Draw Date
e.Graphics.DrawString(strDate, New Font(MyDataGridView.Font, FontStyle.Bold), Brushes.Black, e.MarginBounds.Left + (e.MarginBounds.Width - e.Graphics.MeasureString(strDate, New Font(MyDataGridView.Font, FontStyle.Bold), e.MarginBounds.Width).Width), e.MarginBounds.Top - e.Graphics.MeasureString("Customer Summary", New Font(New Font(MyDataGridView.Font, FontStyle.Bold), FontStyle.Bold), e.MarginBounds.Width).Height - 13)
'Draw Columns
iTopMargin = e.MarginBounds.Top
For Each GridCol As DataGridViewColumn In MyDataGridView.Columns
e.Graphics.FillRectangle(New SolidBrush(Color.LightGray), New Rectangle(CType(arrColumnLefts(iCount), Integer), iTopMargin, CType(arrColumnWidths(iCount), Integer), iHeaderHeight))
e.Graphics.DrawRectangle(Pens.Black, New Rectangle(CType(arrColumnLefts(iCount), Integer), iTopMargin, CType(arrColumnWidths(iCount), Integer), iHeaderHeight))
e.Graphics.DrawString(GridCol.HeaderText, GridCol.InheritedStyle.Font, New SolidBrush(GridCol.InheritedStyle.ForeColor), New RectangleF(CType(arrColumnLefts(iCount), Integer), iTopMargin, CType(arrColumnWidths(iCount), Integer), iHeaderHeight), strFormat)
iCount = iCount + 1
Next GridCol
bNewPage = False
iTopMargin += iHeaderHeight
End If
iCount = 0
'Draw Columns Contents
For Each Cel As DataGridViewCell In GridRow.Cells
If Not IsDBNull(Cel.Value) Then
e.Graphics.DrawString(Cel.Value.ToString(), Cel.InheritedStyle.Font, New SolidBrush(Cel.InheritedStyle.ForeColor), New RectangleF(CType(arrColumnLefts(iCount), Integer), CType(iTopMargin, Single), CType(arrColumnWidths(iCount), Integer), CType(iCellHeight, Single)), strFormat)
End If
'Drawing Cells Borders
e.Graphics.DrawRectangle(Pens.Black, New Rectangle(CType(arrColumnLefts(iCount), Integer), iTopMargin, CType(arrColumnWidths(iCount), Integer), iCellHeight))
iCount = iCount + 1
Next
End If
iRow = iRow + 1
iTopMargin = iTopMargin + iCellHeight
End While
'If more lines exist, print another page.
If bMorePagesToPrint = True Then
e.HasMorePages = True
Else
e.HasMorePages = False
End If
Catch exc As Exception
MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
End Class
|
|
|
|
|
Use your debugger to locate the exact point at which the error occurs and then show just that portion of code (within <pre> tags), and the content of all the local variables. Although, the debugger will clearly show you which object reference has not been initialised.
Use the best guess
|
|
|
|
|
Evord wrote: Hi everybody, am going to show you a sample program We have samples on datagridprinters in the Article-section. This isn't a sample, it's a code-dump with a question. Let's focus on the question and solving it, shall we?
Instead of showing "exc.Message", try "exc.ToString()"; that way the messagebox will show on which line the error occured. That'd be easier in tracing the exception than reading the entire code and checking each line.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
My class is now over. I had an issue with the the assignment. I couldn't get the program to find and display the duplicate random numbers. I've looked for almost two weeks for an answer and I'm hoping that someone here can help me.
This was the assignment:
Present the following report – (you will modify this based on user input and the actual rolls.
Number of dice:2
Number of sides:6
Number of rolls:2
Dice 1 Roll 1 = 5
Dice 2 Roll 1 = 6
Dice 1 Roll 2 = 1
Dice 2 Roll 2 = 1
Number of rolls where all dice were the same: 1
I got everything but the number of rolls where all the dice were the same. Can someone please advise me as to how this should have been done?
Here is a snippet of what I did:
'Start the randomization process
Dim RandomClass As New Random() 'Our random number generator
Dim vRoll() As Integer 'User entered variable for the array
ReDim vRoll(nDice) 'dynamic number entered by the user
Dim cntDice As Integer = 0
Dim myArray As New List(Of Integer)
Dim temp As Integer
myArray.Clear()
'Get the number of rolls and the number of dice and then randomize the rolls.
For i As Integer = 1 To rRoll
For j As Integer = 1 To nDice
temp = RandomClass.Next(1, dSize + 1)
LST_Items.Items.Add("Dice " & j & " Roll " & i & " = " & temp.ToString)
If Not myArray.Contains(temp) Then
cntDice += 1
LBL_Same.Text = cntDice
Else
LBL_Same.Text = "0"
End If
Next
Next
So if anyone is willing to give me advice I would greatly appreciate it.
Thanks!
Troy E Bouchard
|
|
|
|
|
First, you don't need that List. You're not trying to remember every single die roll.
Second, you never compare the roll of the first die to the roll of the second. Once you do that, you simply increment a counter that tracks how many times both dice are equal.
Third, you don't need two for loops, just one.
|
|
|
|
|
You could also sort the list first, then duplicates would show up next to each other.
|
|
|
|
|
Don't need the list at all. Gen the first number on the roll and remember it. For each subsequent die, check it's value against the first die. Finding a non-dupliate is very easy. If you get through the loop withouting finding a non-duplicate, well, you know.
|
|
|
|
|
Hi Guys,
Is it possible to have a list/collection of objects that inherit from a single base object without losing Intelli-sense?
Here is an example of what I mean...
Public Class baseblob
Private _position As PointF
Property position
Get
Return _position
End Get
Set(value)
_position = value
End Set
End Property
Sub New()
position = PointF.Empty
End Sub
End Class
Public Class blob
Inherits baseblob
Sub moveRight(ByVal Distance As Single)
position = New PointF(position.X + Distance, position.y)
End Sub
End Class
Public Class Form1
Dim blob As New blob
Dim blobs As New List(Of baseblob)
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
blob.moveRight(10)
MsgBox(blob.position.x)
blobs.Add(blob)
MsgBox(blobs(0).position.x)
blobs(0).moveright(10)
MsgBox(blobs(0).position.x)
End Sub
End Class
... but of course in the above example i get
'moveright' is not a member of 'oopTest.baseblob'
So it wants me to use
Dim blobs As New List(Of Object)
So it will compile and work as intended...
I just wanted to know is there something I'm missing here? Why can't I just let it know that it's a base object and to list all the possible methods/properties etc of the base class and also any objects that inherit the base class? Give me the lot!
To me it doesn't sound like such a hard thing to ask of the compiler/dev environment... why cant it do it ?
modified 14-May-13 0:36am.
|
|
|
|
|
The method shows up.
In VB.NET, the default access modifier for a class method is Public. In C# it's private.
You'd be better served by not depending on the defaults but explicitly declaring your access levels. Also, your naming convention isn't exactly clean and understandable either. In your example, how do to tell the difference between a variable called blob and your class called blob ?? It should look more like:
Public Class BaseBlob
Private _position As PointF
Public Property Position
Get
Return _position
End Get
Set(value)
_position = value
End Set
End Property
Sub New()
Position = PointF.Empty
End Sub
End Class
Public Class Blob
Inherits BaseBlob
Public Sub MoveRight(ByVal distance As Single)
Position = New PointF(Position.X + distance, Position.y)
End Sub
End Class
Public Class Form1
Private blob As New Blob
Private blobs As New List(Of BaseBlob)
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
blob.MoveRight(10)
MsgBox(blob.Position.x)
blobs.Add(blob)
MsgBox(blobs(0).Position.x)
blobs(0).MoveRight(10)
MsgBox(blobs(0).Position.x)
End Sub
End Class
You can't tell Intellisense to show all members from every class inheriting from a base class. It's not showing you the members of Blob because you told it the collection was a collection of BaseBlob, not Blob. Do you see a member on BaseBlob called MoveRight ?? Nope. So it's not going to show any members that inherit from classes that inherit from BaseBlob because none of them are valid! MoveRight is not applicable to a collection member of blobs because you're are treating the objects in the collection as if they were BaseBlob object. It's telling you that if you try to use one of those members, the compile will fail!
|
|
|
|
|
Thanks for the naming scheme advice. What I use for my project is a lot easier. It was just a quick example. I should have made it easier to read, sorry.
My primary issue is that I need to have multiple class objects that behave differently (playership, enemy drone, missile etc) held in a single container so that my main loop can enumerate through them all.
For example.
For i as integer = 0 to blobs.count - 1
blobs(i).AiTick
blobs(i).Move
blobs(i).Draw
Next i
The only way I could find to do this was to create a base class with the ai/move/draw methods in it and have different classes inherit from the base class and over-ride the base class's methods.
The main issue i have is that these classes that inherit from the base class occasionally have extra methods. I would like to see those when i'm coding things like blobs(0).ExtraMethod like i can for the base class.
I guess what i'm asking isn't possible.
If ClassA inherits BaseClass and ClassB inherits BaseClass but ClassA also has an extra method called "ExtraMethod" then I already run the risk of accidently executing ExtraMethod on the item in the collection that is ClassB and causing an exception. I deal with that issue already in my code, so i don't understand why the dev environment is perfectly fine with me making a list(of Objects) and running List(0).ExtraMethod ... however when I ask it to have a list of BaseClass it doesnt goto the effort of listing what's availiable in any classes that inherit from BaseClass.
I guess I will just continue to have a list(of Object) instead of a list(of BaseClass) and continue running extra methods from classes that inherit from BaseClass as I currently do by first checking the object type.
|
|
|
|
|
Purge1t wrote: I guess what i'm asking isn't possible.
It's not possible because you're trying to violate Object Oriented Programming principles.
You're putting the Move method in one object, when it actually applies to all of the objects. You have to Move the Player, Move the Missle, Move the EnemyDrone, ... Don't use a rather specific MoveRight method. It should be Move and take some kind of value(s) to tell it where to or how far to move. That should go in the Base object that these other objects inherit from.
The same is true for the Draw method. Every object should draw itself, so you pass in a Graphics object that it uses to draw itself on. This is common for every object you mentioned, so it should go in the Base object they are inheriting from, not the specific objects.
By the way, in your case, if you try to execute a method on an object that doesn't implement it, you don't get an exception. You get a compile-time error as the code will not compile.
|
|
|
|
|
Thanks Dave.
Quote: The same is true for the Draw method. Every object should draw itself, so you pass in a Graphics object that it uses to draw itself on. This is common for every object you mentioned, so it should go in the Base object they are inheriting from, not the specific objects.
The PlayerShip class draws a circle, the Missile class draws a triangle and the EnemyDrone class draws a square. How would i know how to depict each different class type if the drawing was done in the base class? Instead of having a MustOverRide .Draw method in the base class that each of the child-classes over-ride ?
|
|
|
|
|
You either have to have that "must override" method or you have to have an interface that every object implements that says justabout the same thing.
You MUST implement something that tells the compiler that "this method is expected in this class" so that you can call it no matter what the class really is.
The drawing is NOT done in the base class. It just provides a "must override" method so that each class can implement it's own drawing code, but since each drawing method implements the exact same method signature, outside code can call it without knowing exactly which type of class it is.
|
|
|
|
|
I am currently trying to convert a String that is gotten from an input box to an Integer using the Try Parse method. The integer is then supposed to be used to fill an array named international. Here is the part of the code that pertains to this:
Dim Count As Integer
For Count = 0 To international.Length - 1
international(Count) = Integer.TryParse(InputBox("Keep entering the sales for each month. If nothing typed, will be interpeted as zero", "New data entry"))
Next Count
I am getting the error message: Overload resolution failed because no accessible 'TryParse' accepts this number of arguments.
How do I fix this?
|
|
|
|
|
|
How to get values from listview and display it to textbox using sql database ?
and then i can update the items in listview using a button..then refresh the listview
after i click the button...all in 1 form
tnx for the help in advance..im just a newbie in vb.net
|
|
|
|
|
Member 10017083 wrote: How to get values from listview Iterate it's items[^].
Member 10017083 wrote: and display it to textbox using sql database ?
You don't display using a database. A database is for storage. To display text in a textbox, change it's text-property.
Member 10017083 wrote: <layer>and then i can update the items in listview using a button..then refresh the listview
after i click the button...all in 1 form
You're describing how the application should work; it'd be a very long post if we'd get detailed into each method you'd be writing. I suggest you start with something simpeler; display some text in a listview, if that works, we can add a button. One step at a time
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|