|
but Image class no contructor
|
|
|
|
|
You are right. I tried to do it myself, and I failed to find a way to inherit from Image.
The documentation mentions the Image class as providing functionality for the Bitmap and Metafile classes. Perhaps it's not meant to be expanded by other classes, e.g. having an internal constructor so that only classes in the same assembly can inherit from it.
---
b { font-weight: normal; }
|
|
|
|
|
Yeah, I know it's kind of weird, but, you can't do this! 8)
The problem is that the constructors for the Image class are tagged internal . This means that only classes inside the same assembly (System.Drawing.dll) can inherit from Image . Stupid, isn't it?
There is no way to directly inherit from Image. But, there is a pseduo-way around it in C#. Check out this[^] discussion. I don't know if the exact same thing can be done in VB.NET yet.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi everybody,
I have a question regarding new events in VS2003. I have read that it is not possible in 2003 but is available in 2005. I have found some code I wish to translate from C# but can't seem to figure it out. Does anyone know how to do this:
public new event DateCancelEventHandler Validating
{
add{this.validating+=value;}
remove
{
try
{
this.validating-=value;
}
catch(Exception ex)
{
throw new ArgumentException(ex.Message ,"Validating");
}
}
}
in vb.net?
thank you
eatwork
-- modified at 18:17 Thursday 4th May, 2006
|
|
|
|
|
Our Instant VB C# to VB converter produces:
Public Shadows Custom Event Validating As DateCancelEventHandler
AddHandler(ByVal value As DateCancelEventHandler)
AddHandler Me.validating, value
End AddHandler
RemoveHandler(ByVal value As DateCancelEventHandler)
Try
RemoveHandler Me.validating, value
Catch ex As Exception
Throw New ArgumentException(ex.Message,"Validating")
End Try
End RemoveHandler
RaiseEvent(ByVal sender As Object, ByVal e As EventArgs)
End RaiseEvent
End Event
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter and VB to C++ converter
Instant J#: VB to J# converter
Clear VB: Cleans up VB.NET code
Clear C#: Cleans up C# code
|
|
|
|
|
Hello David,
Thank you for your response. I have tried the code you supplied, but it does not seem to work in VS2003. It says that an end of statement is expected on the line "Event Validating As DateCancelEventHandler" and everything else after that generates some code errors. Do you know if it is possible to create custom events in VB.net, similar to those in C#? Thanks
eatwork
|
|
|
|
|
Custom events are not available in VB 2003.
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter and VB to C++ converter
Instant J#: VB to J# converter
Clear VB: Cleans up VB.NET code
Clear C#: Cleans up C# code
|
|
|
|
|
Hi all
Im having trouble displaying part of my structure when reading it back out of an array
basicly
i read in from a csv file
grab the user name and the total the use was charged
create a entry into a sorted list useing the usersname as the key
then for the value i have a collection and add the name , department , total)
if the user shows up again while going through the csv file i will simply add the total to the existing total
when i watch the variables in the watcher everything adds up fine
but when i display it it comes out as the first entry into the collection
Now i first thought mabey it was just doing something funky with the conversion between int and dec or soemthing like that
but then i checked in the csv file and 47.02 is the frist entry for this user
so basicly i am completely lost
Screenshot
http://i1.tinypic.com/x3ww3b.png
-- modified at 16:34 Thursday 4th May, 2006
|
|
|
|
|
<br />
Imports System.IO<br />
Imports System.Text.Encoding<br />
Imports System.Text.RegularExpressions<br />
<br />
Public Class Form1<br />
<br />
Private Sub ExitToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click<br />
Me.Close()<br />
End Sub<br />
<br />
Private strSourcePath As String<br />
Dim ipassinfo As New SortedList<br />
Public Structure user<br />
'Declare data members<br />
Public username As String<br />
Public department As String<br />
Public domestictotal As Decimal<br />
End Structure<br />
Dim userinfo As New user<br />
Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click<br />
Tb_totals.Clear()<br />
tb_usertotals.Clear()<br />
tb_linesproccessed.Clear()<br />
<br />
<br />
With Me.OpenFileDialog1<br />
.InitialDirectory = "C:\"<br />
' The file could be of any type. The Filter is restricted to Text Format <br />
' files only for demonstration purposes.<br />
.Filter = "Tab delmited (*.csv)|*.csv"<br />
.FilterIndex = 1<br />
<br />
' The OpenFileDialog control only has an Open button, not an OK button.<br />
' However, there is no DialogResult.Open enum so use DialogResult.OK.<br />
If .ShowDialog() = Windows.Forms.DialogResult.OK Then<br />
strSourcePath = .FileName<br />
<br />
<br />
Dim datipass As New StreamReader(.FileName)<br />
'*'' Dim totalChargeByName As New SortedList<br />
Dim fields As String()<br />
Dim count As Int16<br />
<br />
Do Until datipass.Peek() = -1<br />
Dim MyLine As String = datipass.ReadLine<br />
Dim myparse As String<br />
<br />
'create variable for "'"<br />
myparse = (ControlChars.Quote & "," & ControlChars.Quote)<br />
'Replace "," with tab's<br />
MyLine = MyLine.Replace(myparse, ControlChars.Tab)<br />
'remove certian words<br />
MyLine = MyLine.Replace("usatoday\", "")<br />
MyLine = MyLine.Replace("eu\", "")<br />
'forces everythign to lower<br />
MyLine = MyLine.ToLower<br />
'break feild up on tabs<br />
fields = MyLine.Split(ControlChars.Tab) 'Or Convert.ToChar(Keys.Tab)<br />
<br />
<br />
'check to see if entrie already exists if not create it<br />
If ipassinfo(fields(2)) Is Nothing Then<br />
'loading the structure<br />
userinfo.username = fields(2)<br />
userinfo.department = "???"<br />
userinfo.domestictotal = fields(9)<br />
'adding the structure to the sortedlist under key username<br />
ipassinfo.Add((fields(2)), userinfo)<br />
Else<br />
' adds charges to total if allready exists<br />
userinfo.domestictotal = userinfo.domestictotal + fields(9)<br />
End If<br />
count = count + 1<br />
Loop<br />
Me.tb_linesproccessed.Text = count<br />
'release the access of the file<br />
datipass.Close()<br />
<br />
Dim x As String<br />
Dim y As Decimal<br />
Dim total As Decimal<br />
Dim i As Integer<br />
<br />
For i = 0 To ipassinfo.Count - 1<br />
x = ipassinfo.GetKey(i)<br />
<br />
y = DirectCast(ipassinfo.GetByIndex(i), user).domestictotal <-------------- here is where i am having the trouble<br />
total = y + total<br />
<br />
tb_usertotals.AppendText(x.PadRight(20) & ControlChars.Tab & y.ToString("C") & vbNewLine)<br />
Me.tb_usersmade.Text = i<br />
Next i<br />
Me.Tb_totals.Text = total.ToString("c")<br />
<br />
End If<br />
End With<br />
End Sub<br />
-- modified at 16:36 Thursday 4th May, 2006
|
|
|
|
|
Hi All,
I'm using VB6 to retrieve the database table's schema. I have another routine that returns the some of the table Fields schema information, but it dosn't label the primary key field.
Here are the routines I'm using:
Private Sub List_DB_Tables(cnnDB As ADODB.Connection)
On Error GoTo List_DB_Tables_Err
Dim itmX As ListItem
Dim lngLen As Long
lvTables.ListItems.Clear
lvFields.ListItems.Clear
Set rstSchema = cnnDB.OpenSchema(adSchemaTables)
With rstSchema
Do Until .EOF
If (UCase(!TABLE_TYPE) = "ACCESS TABLE") Or (UCase(!TABLE_TYPE) = "SYSTEM TABLE") Then
.MoveNext
Else
Set itmX = lvTables.ListItems.Add(, , !TABLE_NAME)
Call AutoSizeColumn(lvTables, 0)
itmX.SubItems(1) = !TABLE_TYPE
Call AutoSizeColumn(lvTables, 1)
.MoveNext
End If
Loop
End With
List_DB_Tables_Exit:
On Error Resume Next
rstSchema.Close
Set rstSchema = Nothing
Exit Sub
List_DB_Tables_Err:
Msg = "Error in frmMainMenu - List_DB_Tables subroutine. " & vbCr & _
"Error # " & Str(Err.Number) & " was generated by " _
& Err.Source & vbCr & Err.Description
MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext
Resume List_DB_Tables_Exit
End Sub
Private Sub List_Fields_In_Table(cnnDB As ADODB.Connection, strTable As String)
On Error GoTo List_Fields_In_Table_Err
Dim itmX As ListItem
Dim J As Integer
Dim fld As ADODB.Field
Dim prp As ADODB.Property
lvFields.ListItems.Clear
Set rstSchema = New ADODB.Recordset
strSQL = "SELECT " & strTable & ".* FROM " & strTable & ";"
rstSchema.Open strTable, cnnDB, , , adCmdTable
' Enumerate the Fields collection of the strtable
For Each fld In rstSchema.Fields
Set itmX = lvFields.ListItems.Add(, , fld.Name)
Call AutoSizeColumn(lvFields, 0)
itmX.SubItems(1) = FieldType(fld.Type)
Call AutoSizeColumn(lvFields, 1)
Next fld
'reset the dynamic array size
arryElements = lvFields.ListItems.Count
ReDim arryFields(arryElements)
'Load array with field names
For J = 1 To arryElements
arryFields(J) = lvFields.ListItems(J).Text
Next J
List_Fields_In_Table_Exit:
On Error Resume Next
rstSchema.Close
Set rstSchema = Nothing
Exit Sub
List_Fields_In_Table_Err:
Msg = "Error in frmMainMenu - List_Fields_In_Table subroutine. " & vbCr & _
"Error # " & Str(Err.Number) & " was generated by " _
& Err.Source & vbCr & Err.Description
MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext
Resume List_Fields_In_Table_Exit
End Sub
|
|
|
|
|
Frequently I need to overlay new files to be tested on top of GA software. I have to search for the location of the where the original files reside, rename the original files, copy over the new files, run tests, then delete the overlay files and rename the originals back.
This can turn into a major headache if I have 50 files to overlay and they are in multiple directories!
I have searched high and low and I can't find any code/utility that can do any of this! I have created a utility toolbar in vb.net that and would like to add a tool that has this functionality – User points to location of files to be tested and tool places them in the proper location and backs up the originals. When the user is done the click another button and the originals are renamed back(I can handle this part!). Just looking for a point in the right direction to get started (or if someone knows of an object that does it already!!).
Thanks all!
Ern
|
|
|
|
|
Greetings!
I have made a report using a built in report form in vb6. It is working already. but my problem is when I add a new record to a certain database and view the report i made, it does not appear on it unless I close my program and run it again.
Just to make sure that the data is saved to the database, after entering the data and clicking save, I open the ms database and see to it if the record has been added or not. 100% it is there already but when I view my report attatch to my program, it does not appear there unless I quit my program and run again.
What is the posible cause of this of what shall i do to my program to make my report accurate.
Please help me...
Thank you very muc in advance....
|
|
|
|
|
Please post your code on the forum. It is easy for everyone to debug it.
|
|
|
|
|
Hello to all of you there....
I am new to Visual Basic Programming.
I just want to know How to find record in a ms Database? I am using Do while not rs.eof but I think if my database is populated with thousand of records it will run slow. So, is there any command or way how to find record in a database? Like in CLIPPER or FOXPLUS Language, I use SEEK <string> to find a record in a database.
Hope you could help me... thnka you very much.
|
|
|
|
|
Give the users the ability to format text, and someone will find a way to Abuse it.
Use where in the query you use to get the recordset to specify what record you want.
Example:
strSQL = "select this, that from somewhere where something = " & somevalue
---
b { font-weight: normal; }
|
|
|
|
|
Greetings. I have a (Janus) datagrid on a windows form that includes a checkbox column (bound to a bit field in a SQL database). I have a save button on the form that calls the update method on the grid's underlying table's data adapter.
If you check the checkbox and then click the save button, it does not update because the edit from the checkbox control has not made it to the data table, so the row does not appear to be modified to the data adapter.
How can I detect when a grid edit control has been changed, but the data it is bound to has not? And how can I make the datatable pick up the chnage so I can call update on the data adapter?
Thank you very much.
RH
|
|
|
|
|
Hello,
I've been searching the net on how to execute a dialup connection and came up with the following code:
<br />
Imports System.Runtime.InteropServices<br />
<br />
Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long<br />
Private Declare Function InternetAttemptConnect Lib "wininet" (ByVal dwReserved As Long) As Long<br />
Const scUserAgent = "ISP_Dialup"<br />
Const INTERNET_OPEN_TYPE_PRECONFIG = 0<br />
Public Function ConnectToSISP() As Boolean<br />
Dim hInternet As Long<br />
If InternetAttemptConnect(0) <> 0 Then Exit Function<br />
hInternet = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)<br />
ConnectToSISP = (hInternet <> 0) 'return False if hInternet=0<br />
End Function<br />
When my code reaches this point If InternetAttemptConnect(0) <> 0 Then Exit Function I receive a message that states PInvoke stack balance detected... A call to PInvoke function 'Project1!Project1.Dialup::InternetAttemptConnect' has unbalanced the stack.
I'm thinking maybe some how I am not referencing wininet.dll properly...any suggestions is greatly appreciated.
Rashar
|
|
|
|
|
Rashar wrote: Private Declare Function InternetAttemptConnect Lib "wininet" (ByVal dwReserved As Long) As Long
Try changing that to...
Private Declare Function InternetAttemptConnect Lib "wininet" (ByVal dwReserved As Integer) As Integer Hope that helps
In fact I think InternetOpen will also throw this error - you will need to change the parameters lAccessType As Long and lFlags As Long to be Integer s, as well as the return value.
You can use pinvoke.net[^] to look for Win32 API method signatures in C# and VB.Net.
“Accept that some days you are the pigeon, and some days you are the statue” -- David Brent
Cheers,
Will H
-- modified at 13:32 Thursday 4th May, 2006
|
|
|
|
|
Hello has anyone got a list of arrays and boolean methods that can be used when creating a sudoku solver, for VB.NET. If so could you please let me know.
Thank you
Passion
|
|
|
|
|
There are many examples of Soduku Solver applications on this site if you search the articles.
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
i have a list of names in a database which appears in a combobox which i have created. i want to be able to delete a selected item from the combobox and database with a delete button but i don't know the code for that. please help me
|
|
|
|
|
Are you loading the combobox from the database using a subroutine? I have some code that does what you are asking for, but my methods might be a bit different. I'll get them put together and post it in a bit.
Quecumber256
|
|
|
|
|
Moveman,
Here is the code I have. I'll try to explain the method to my madness. BTW, you can use this code for both combo and list boxes.
Step 1 - Load the combo box using a subroutine.
Private Sub Load_lstCourses()
'Load the Student course listbox.
On Error GoTo Load_lstCourses_Err
Dim strItem As String
'Clearing the list box
lstCourses.Clear
'Load the lstCourse listbox
Set rsData = New ADODB.Recordset
strSQL = "SELECT * FROM usystblCourses WHERE (((usystblCourses.intDeleted)=False));"
rsData.Open strSQL, cnnMainDb, adOpenKeyset, adLockReadOnly
With rsData
Do While .EOF = False
lngCourse = !lngCourseID
strItem = !txtCourseName
lstCourses.AddItem strItem
lstCourses.ItemData(lstCourses.NewIndex) = lngCourse
.MoveNext
Loop
End With
Load_lstCourses_Exit:
On Error Resume Next
rsData.Close
Set rsData = Nothing
Exit Sub
Load_lstCourses_Err:
Msg = "Error in frmCourses - Load_lstCourses Subroutine. " & vbCr & _
"Error # " & Str(Err.Number) & " was generated by " _
& Err.Source & vbCr & Err.Description
MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext
Resume Load_lstCourses_Exit
End Sub
Step 2 - Code to delete the selected item from the combobox. I'm using MS-Access as my DB
Private Function Delete_Course(lngCourse As Long) As Boolean
On Error GoTo Delete_Course_Err
cnnMainDb.BeginTrans
strSQL = "UPDATE usystblCourses SET usystblCourses.dtmModified = Now(), " & _
"usystblCourses.intDeleted = True WHERE " & _
"(((usystblCourses.lngCourseID) = " & [lngCourse] & "));"
Set cmdChange = New ADODB.Command
Set cmdChange.ActiveConnection = cnnMainDb
cmdChange.CommandText = strSQL
Set rsData = New ADODB.Recordset
rsData.Open "usystblCourses", cnnMainDb, , , adCmdTable
cmdChange.Execute
DoEvents
Msg = "Do you wish to delete " & lstCourses & "?"
intResponse = MsgBox(Msg, vbYesNo + vbDefaultButton2 + vbQuestion, "Deleting Cosmetology Course")
If intResponse = vbYes Then
cnnMainDb.CommitTrans
Delete_Course = True
Else
cnnMainDb.RollbackTrans
Delete_Course = False
End If
Delete_Course_Exit:
On Error Resume Next
rsData.Close
Set rsData = Nothing
Exit Function
Delete_Course_Err:
Msg = "Error in frmCourse - Delete_Course function " & vbCr & _
"Error # " & Str(Err.Number) & " was generated by " _
& Err.Source & vbCr & Err.Description
MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext
Resume Delete_Course_Exit
End Function
Step 3 - Know which item you want to delete.
Private Sub cboCourses_Click()
lngCourse = CLng(cboCourses.ItemData(cboCourses.ListIndex))
End Sub
Step 4- Delete the item. I had a routine to check and make sure an item was selected before I deleted it.
Private Sub cmdDelete_Click()
If Is_Data_Present Then 'Checking routine
If Delete_Course(lngCourse) Then
Msg = lstCourses & " has been deleted."
MsgBox Msg, vbInformation, "Deleting item."
Else
Msg = lstCourses & " has NOT been deleted."
MsgBox Msg, vbInformation, "Deleting item."
End If
Else
Msg = "Before you can delete an item you must double click on the item name " & _
"you wish to delete. " & vbCr & _
"The item name must be placed into the Course Name box " & _
"before I can remove it from the database."
MsgBox Msg, vbInformation, "Deleting item."
End If
Call Load_lstCourses
txtCourse.Text = Empty
txtCourse.SetFocus
End Sub
I hope this helps,
Quecumber256
|
|
|
|
|
You will find lots of useful .Net material in this site
Visit this site
http://www.dotnetguide.co.nr
:->
|
|
|
|
|
|