|
In your user control define an event like:
Public Class UserControl1
Public Event Deleting(ByRef bCancel As Boolean)
Public Event Deleted()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim bDel As Boolean
RaiseEvent Deleting(bDel)
If bDel = True Then Exit Sub
'DELETE CODE HERE
RaiseEvent Deleted()
End Sub
End Class
The form you are using your control in, you should see the events like:
Public Class Form1
Private Sub UserControl11_Deleting(ByRef bCancel As Boolean) Handles UserControl11.Deleting
'CHECK YOUR CONDITION HERE, YOU CAN OPTIONALLY SET bCancel=TRUE
'IF YOU WANT TO ABORT THE DELETE BEING DONE IN YOUR USER CONTROL
End Sub
Private Sub UserControl11_Deleted() Handles UserControl11.Deleted
MSGBOX "Item Deleted"
End Sub
End Class
Hope this helps!
~ CodeDoctor ~
|
|
|
|
|
Hi!
How can I save the fontdialog or colordialog settings to a text file(to a path I have chosen), then retrieve it again and assign it back to my program.
thanks in advance.
|
|
|
|
|
If i were you, i'd save the settings in the register using the SaveSetting(..) method, and to retrieve the data again by using the GetSetting(..) method. It almost always works at me
Example:
SaveSetting("Program Name", "Settings", "Color", ColorDialog1.Color)
SaveSetting("Program Name", "Settings", "Font", FontDialog1.Font.FontFamily.ToString)
Enjoy
--Zaegra--
|
|
|
|
|
thanks, but; can you give me a complete example on how to save and retrieve.
|
|
|
|
|
hello all,
am creating one small project using vb and msaccess. my problem is i have a field name barcodeno in it i want incremental values. for example i have a partno in that Part no it self contain 1200 different Barcodeno i cant even enter one by one so am in need of some auto incremental mechanism. start value and end value only recevied in different text boxes. Annnnnnnnnny Ideas Please Help me.......
Thanks in advance
|
|
|
|
|
There's not enough information on the problem to tell you anything. ALl we have is you have field that holds 1200 BarCodeNo's and you need to increment the BarCodeNo value.
Increment how? Are you looking to get the last BarCodeNo in the database and increment it? Are you looking to autogenerate all the BarCodeNo's between two values (entered in TextBox's) and store them in the database? ??????
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Hello Mr.Dave,
Thanks For Your reply. s am looking autogenerate all the barcode no's between two values and store them in the database. Please help me is it possible? and further how can we insert Bulk data's in the database (ie More than 300 rows at a time by cliclking a Button like "save"). am a begginer Please help me.
|
|
|
|
|
Creating the records for the barcodes isn't that hard. You already know how to add records to a database in your code. All you have to do is enclose that in a loop and start inserting new records, one at a time.
If all you're doing is creating records that have nothing but a barcode, why are you even creating them? Normally, you wouldn't do this until you actually assigned the barcode to an item and entered the details of the item into the database.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
hello Am a beginer only i dont know how to increment a value in a datagrid and also the bulk insert in MSAccess. at a time we can only enter one row in a database but in my project for exammple they have one product, that product belonging from one company but that particular product contain 100 different barcode no in that case only i need increment mechanism. am creating text boxes for enter product and company name below that a datagrid for enter all barcode for that product whenever i submit all the barcode and then press a add button 100 rows will automatically enter into a database. is it possible or not? if possible how? Please give me any example code
|
|
|
|
|
rrrriiizz wrote: Am a beginer only
Nothing like jumping into the deep end of the pool without knowing how to swim! You don't know what you're doing. This is what is making this description so hard. I'll simplify this as much as I can.
When you create the barcode records, you don't have to put the barcodes in a DataGrid. Actually, you don't ever insert them into a DataGrid. All you do is create the barcodes using an SQL INSERT (OleDbCommand object) directly into your table, inside a for/next loop.
When those records are completed, you requery the database using a SELECT statement and a OleDataAdapter object, to retrieve the records between the beginning barcode and ending barcode numbers, filling a DataTable with the results.
You then bind the DataGrid to the DataTable. Your user can then start entering the information about each barcode into the table. When they're done, you write the information back to the database using the same OleDbDataAdapter you created to fill this table.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Good day!
I have a problem about hiding and unhiding a web objects in AxWebBrowser using VB.Net.
Our teacher's condition are:
(1) There must be a command button outside the AxWebBrowser. The command button will generate a random number from 1 to 4.
(2) After generating random number it automatically select a value in a listbox inside the AxWebBrowser.
(3) Every value of a listbox theres a corresponding control that show and hide the other objects.
Mark Angelus V. Movida
Student
|
|
|
|
|
How do you intend to approach it ? With this sort of thing, often there's more than one way to do something, your teacher will expect you to do it in the way you've been shown. What have you been shown to do in this case ? What have you got working already ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
There is several ways to approach this.
First, get a reference to the Document object within the AxWebBrowser.
The best time to get this reference is on the DocumentCompleted event.
This will give you access to the underlying objects contained within.
You can optionally tie into the eventing of the browser object itself. But you'll need a reference a COM library Microsoft Internet Controls and another one for Microsoft HTML Object Library.
With references to these two libraries, you can declare the Document object WithEvents. Assign the Document to local (withevents) variable. Then place code in the event of that variable's event procedures.
This techique I've used, and you can ultimately do pre and post processing on any HTML objects that show in the page. In addition, you can gain full control over the Styles used within the HTML. For instance, you can set Styles dynamically on the HTML elements once you gain a reference to them.
Lastly, you can gain access to the Window object contained through the reference to the Document object. Then you can detect any of the areas the mouse is over or on.
Hope this helps!
~ CodeDoctor ~
|
|
|
|
|
Connect DVR Card for capture Pic.
|
|
|
|
|
DirectShow
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
Hi in sqlserver stored procedure i am doing some calculations...,
See the below procedure:
select a.empid,b.empName,c.Whrs,c.srg,case when srg=0 then @Outsunday else @Insunday end as days,c.Bassalary,
(Bassalary/(days*Whrs)) as onehour,
sum(AppWHours) as TWhrs,Sum(AppOtHours) as TOThrs
from tblMonthHourDetails a,tblemployeemaster b,tblsalarydetails c where
a.empid=b.empid and a.empid=c.empid and
b.projectid=@projectid and datepart(mm,[SDate])=@months and datepart(yy,[SDate])=@Years group by a.empid,b.empName,c.Whrs,c.srg,c.Bassalary
In that above procedure using case condition i am getting one column "days" like...,
That days value i want to use to calculate for onehour column,
if i give there days(highlighted in above procedure) value its telling error msg like invalid column days like...,
but i want to use that value there how to use...,
Plz any one solve my probs.....,
Magi
|
|
|
|
|
You can do a nested query, but this is probably better:
case when srg=0 then (Bassalary/(@Outsunday*Whrs)) else (Bassalary/(@Insunday *Whrs))end as onehour
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thank u for ur reply...,
But i did like this:
Bassalary/((case when srg=0 then @Outsunday else @Insunday end)*Whrs) as onehour
Any way once again thanks for ur reply
Magi
|
|
|
|
|
Stored VB.Net procedures consisting of many subroutines and a few functions
working with one SQL Server 2005 datbase. The problem is as follows:
Sub A receives a table name, a query name, and a directory path name.Using
Dim RecordTypeSet As SqlDataReader
Dim RecordTypeConnection As New SqlConnection
Dim RecordTypeCommand As New SqlCommand I open a reader
from the sql located at directory path name & query name
and While RecordTypeSet.Read()
I create a record which I want to store in the table name provided.
In order to do this I call a SUB B with the record and the Table name.
Sub B builds an insert query and using
Dim SummaryConnection As SqlConnection
Dim SummaryCommand As SqlCommand
Dim SummaryReader As SqlDataReader
SummaryConnection = New SqlConnection("context connection = true")
SummaryConnection.Open()
SummaryCommand = New SqlCommand(sql, SummaryConnection)
SummaryReader = SummaryCommand.ExecuteReader()
errors out on SummaryConnection.Open()
end sub B
wend
rkj
|
|
|
|
|
reykentj wrote: SummaryConnection = New SqlConnection("context connection = true")
What's the error?? Why does everyone leave out the error description when they post "I have a problem!"?
Does the method that this error occurs in have the SqlProcedure attribute on it?
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Sub_A
Dim sql As String = ""
Dim rdr1 As SqlDataReader
Dim conn1 As New SqlConnection
Dim cmd1 As New SqlCommand
sql = ReadAllText from textfile
conn1 = New SqlConnection("context connection = true")
conn1.Open()
cmd1 = New SqlCommand(Sql, conn1)
rdr1 = cmd1.ExecuteReader()
While rdr1.Read()
build record REC_A
Sub_B (REC_A)
SUB_B
Dim sql As String = ""
Dim rdr2 As SqlDataReader
Dim conn2 As New SqlConnection
Dim cmd2 As New SqlCommand
Builds SQl Query to insert record into some table
conn2 = New SqlConnection("context connection = true")
conn2.Open() ABORTS HERE
eND sUB_b
wend
End Sun_A
With SqlProcedure Attribute I get a deployment error on SUB_A
because it has a Byref Class instantiation to return data to the caller
rkj
|
|
|
|
|
This is utterly useless. Copy and Paste the code in a post. The "Sub_A" crap leaves out details that are required to see what's going on.
You also didn't answer my question. Does the "sub" have an SqlProcedure attribute? Copying and pasting the code probably would have showed that! And, the EXACT error message would help more, not your interpretation of it.
The "context connection = true" only works inside an SqlProcedure attributed function. Without it, you may as well use a seperate connection using a normal connection string.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
I did not originally have the sql server attribute declared
Your first question prompted me to insert that and try again.
When I did, I got a deployment error on the byref use. I am currently
trying to find another attribute to solve that problem. Here is the code
<microsoft.sqlserver.server.sqlprocedure()> _
Public Shared Sub sbBuildRecordTypeProfitnLossTable(ByVal Account_Summary_Name As String, _
ByVal RecordTypeQueryName As String, _
ByVal DirectoryPath As String, _
ByVal Run_Select As Long, _
ByVal Department As String, _
ByVal Record_Type As Single, _
ByVal record_count As Long, _
ByVal Pdate As Date, _
ByRef PL_Return As Profit_Loss_Return)
Dim Wrec As New Profit_Loss_Summary_Record
Dim ProfitnLossRec As New Profit_Loss_Summary_Record
Dim wSalesRec As New Profit_Loss_Summary_Record
Dim TotMonthly_Item As Decimal = 0
Dim TotYearly_Item As Decimal = 0
Dim result As Long = 0
Dim SalesAccountNo As Long = 0
Dim AccountStor As Long = 0
Dim StrSalesAccountNo As String = ""
Dim CGAccountNo As Long = 0
Dim Branch_Name As String = ""
Dim ReturnValues As New Profit_Loss_Return
Dim wdepartment As String = ""
Dim sql As String = ""
Dim RecordTypeSet As SqlDataReader
Dim RecordTypeConnection As New SqlConnection
Dim RecordTypeCommand As New SqlCommand
On Error GoTo Err_sbBuildRecordTypeProfitnLossTable
sql = File.ReadAllText(DirectoryPath & RecordTypeQueryName)
RecordTypeConnection = New SqlConnection("context connection = true")
RecordTypeConnection.Open()
RecordTypeCommand = New SqlCommand(Sql, RecordTypeConnection)
RecordTypeSet = RecordTypeCommand.ExecuteReader()
While RecordTypeSet.Read()
AccountStor = RecordTypeSet!AccountNo
If AccountStor = 53410 Then
record_count = record_count
End If
sbBuildSummaryProfitnLossTableRec(RecordTypeSet, Record_Type, Department, Pdate, ProfitnLossRec)
If Record_Type = 2 Then
CGAccountNo = ProfitnLossRec.AccountNo
SalesAccountNo = CGAccountNo - 10000
StrSalesAccountNo = SalesAccountNo
sbGetSummaryRec(Account_Summary_Name, SalesAccountNo, wSalesRec)
If wSalesRec.AccountNo <> StrSalesAccountNo Then
wSalesRec = ProfitnLossRec
wSalesRec.AccountNo = SalesAccountNo
wSalesRec.Monthly_item = 0
wSalesRec.Yearly_item = 0
wSalesRec.Record_Type = 1
wSalesRec.Record_Type_Name = "Sales"
wSalesRec.Description = Wrec.Description
record_count = record_count + 1
sbUpdateSummaryProfitnLossTableRecord(Account_Summary_Name, wSalesRec, record_count)
Else
End If
End If
TotMonthly_Item = TotMonthly_Item + ProfitnLossRec.Monthly_item
TotYearly_Item = TotYearly_Item + ProfitnLossRec.Yearly_item
record_count = record_count + 1
If ProfitnLossRec.AccountNo = 53410 Then
record_count = record_count
End If
If Run_Select = 3 Then
ProfitnLossRec.Branch_Name = ""
End If
sbUpdateSummaryProfitnLossTableRecord(Account_Summary_Name, ProfitnLossRec, record_count)
End While
Branch_Name = ProfitnLossRec.Branch_Name
RecordTypeSet.Close()
RecordTypeCommand.Dispose()
RecordTypeConnection.Close()
ReturnValues.record_count = record_count
ReturnValues.Monthly_Total = TotMonthly_Item
ReturnValues.Yearly_total = TotYearly_Item
ReturnValues.Branch_Name = Branch_Name
PL_Return = ReturnValues
Exit_sbBuildRecordTypeProfitnLossTable:
Exit Sub
<microsoft.sqlserver.server.sqlprocedure()> _
Public Shared Sub sbUpdateSummaryProfitnLossTableRecord(ByVal ProfitnLossName As String, _
ByVal Wrec As Profit_Loss_Summary_Record, _
ByVal record_count As Long)
Dim sql As String
Dim crlf As String = ""
Dim Quote As String = ""
Dim SummaryProfitConnection As SqlConnection
Dim SummaryProfitCommand As SqlCommand
Dim SummaryProfitReader As SqlDataReader
On Error GoTo err_sbUpdateSummaryProfitnLossTableRecord
If fnProfitNLossNotZeroRecord(Wrec) Then
crlf = Chr(13) & Chr(10)
Quote = Chr(39)
sql = ""
sql = sql & "Insert INTO " & ProfitnLossName & crlf
sql = sql & "(" & crlf
sql = sql & " Record_Index" & crlf
sql = sql & ", Record_Type" & crlf
sql = sql & ", Record_Type_Name" & crlf
sql = sql & ", Branch_Name, Department" & crlf
sql = sql & ", AccountNo" & crlf
sql = sql & ", Description" & crlf
sql = sql & ", Monthly_Item" & crlf
sql = sql & ", MonthlyPercent" & crlf
sql = sql & ", Yearly_Item" & crlf
sql = sql & ", YearlyPercent" & crlf
sql = sql & ", LastEffectiveDate" & crlf
sql = sql & ", Asofdate" & crlf
sql = sql & ")" & crlf
sql = sql & "Values ( " & crlf
sql = sql & record_count & crlf
sql = sql & "," & Quote & Wrec.Record_Type & Quote & crlf
sql = sql & "," & Quote & Wrec.Record_Type_Name & Quote & crlf
sql = sql & "," & Quote & Wrec.Branch_Name & Quote & crlf
sql = sql & "," & Quote & Wrec.Department & Quote & crlf
sql = sql & "," & Quote & Wrec.AccountNo & Quote & crlf
sql = sql & "," & Quote & Wrec.Description & Quote & crlf
sql = sql & "," & Quote & Wrec.Monthly_item & Quote & crlf
sql = sql & "," & Quote & Wrec.MonthlyPercent & Quote & crlf
sql = sql & "," & Quote & Wrec.Yearly_item & Quote & crlf
sql = sql & "," & Quote & Wrec.YearlyPercent & Quote & crlf
sql = sql & "," & Quote & Wrec.LastEffectiveDate & Quote & crlf
sql = sql & "," & Quote & Wrec.AsofDate & Quote & crlf
sql = sql & ");" & crlf
End If
SummaryProfitConnection = New SqlConnection("context connection = true")
SummaryProfitConnection.Open() "ABORTED HERE without SQl Attribute. Cannot get here with it!!"
SummaryProfitCommand = New SqlCommand(Sql, SummaryProfitConnection)
SummaryProfitReader = SummaryProfitCommand.ExecuteReader()
SummaryProfitCommand.Dispose()
SummaryProfitConnection.Close()
exit_sbUpdateSummaryProfitnLossTableRecord:
Exit Sub
err_sbUpdateSummaryProfitnLossTableRecord:
fnHandleError("sbUpdateSummaryProfitnLossTableRecord")
Resume exit_sbUpdateSummaryProfitnLossTableRecord
End Sub
rkj
|
|
|
|
|
reykentj wrote: "ABORTED HERE without SQl Attribute. Cannot get here with it!!"
It "aborted" with what error message?!! Do you actually want help? This is the third time you've been asked for the error message. Why are you being so evasive?
I'd love to help, but I'm not going to read through the code looking for the cause of an error until I know what error I'm supposed to be looking for.
|
|
|
|
|