|
A picture box can be set to do this for you automatically.
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 )
|
|
|
|
|
Picture box will resize itself to the size of picture.
But i want to resize the picture according to the size of picture box.
|
|
|
|
|
No, a picture box does not resize itself, it stretches the image to fit itself.
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 )
|
|
|
|
|
Actually it does both. It all depends on the sizemode that's been selected.
|
|
|
|
|
OK, I knew there were different modes, I had no idea one of those actually resizes the picturebox. But then, I'd never use a picture box in my code.
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 )
|
|
|
|
|
Hey everyone, just got an assignment to create an app to take a complex equation (i.e. 20+4/2-6*3) and compute it. I know that you need to take the expression and put it into postfix notation, but how do get to that point and how do I calculate it. I don't usually ask, but we just got the assignment this week and I leave for another class in Chicago over the weekend, so I will be pressed to get it done before Tuesday.
Any ideas to help me on my way?
|
|
|
|
|
Perhaps check for occurences of the functional characters and return substrings between them, then calculate in the correct order via BDMAS (Brackets, Division, Multiplication, Addition, Subtraction). The actual code i don't know for sure but i'll have a go at it for you.
Posted by The ANZAC
|
|
|
|
|
This is a truly complex project. One beyond my skill. As far as i can work out, you need to split the string at the specific locations, take note of the function at that point, split the equation either side of it, then priorise the calculations according to the order of operations. Sounds simple, the code is more difficult. I hope this has helped.
Posted by The ANZAC
|
|
|
|
|
Yeah, I've got it set up now to split the original equation (which is in string format) on the condition on whether of not you have a number or an operator. The operator goes to a stack while the numbers go to an array list. The operators only get popped out of the stack based on the conditions of solving a complex equation, but the problem I am having is when I check the next item in the string to make sure that it isn't another part of the number.
|
|
|
|
|
Okay, I figured out how to get the postfix order. Yesterday I remembered that in a data structures class, we built a c++ program that did the same, but we only used variables and didn't do any equation solving. Luckily, I never sell back my CS school books, and I had seen my old data structures book in our storage just last Sunday, so I pulled it out and got the program half way finished. So all I have left is to do the solving.
|
|
|
|
|
I have a Class (Class1) and a Form (Form1)that have a object (cl as Class1)
Whene I added a first new DataRow to a DataTable in cl a Sub (Row_Changed)was called One time
and Whene I added a Second new DataRow to a DataTable in cl a Sub (Row_Changed)was calling two times
I Want a Sub was called One time
------------------------------------------------------------------------------
Public Class Class1
Public Dt As New DataTable
Dim N As Integer
Sub New()
End Sub
Private Sub Row_Changed(ByVal Sender As Object, ByVal e As DataRowChangeEventArgs)
If e.Action = DataRowAction.Add Then
e.Row(1) = N - 1
MsgBox(e.Action.ToString & Str(N) & "," & e.Row(1))
End If
End Sub
Public Sub Start()
AddHandler Dt.RowChanged, AddressOf Row_Changed
End Sub
End Class
--------------------------------------------------------------------------------
Public Class Form1
Dim N As Integer
Dim Cl As New Class1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TestDataSet.Tables(0) has Two Column
Cl.Dt = TestDataSet.Tables(0)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Cl.Start()
Dim Dr As DataRow
N += 1
Dr = Cl.Dt.NewRow
Dr(0) = N
Dr(1) = Str(N)
Cl.Dt.Rows.Add(Dr)
End Sub
End Class
|
|
|
|
|
I only looked breifly, but you could remove the handler after the sub has been called once...Just put
RemoveHandler Dt.RowChanged, AddressOf Row_Changed
right after MsgBox(e.Action.ToString & Str(N) & "," & e.Row(1))
in Private Sub Row_Changed
Apparently it's not OK to start a bonfire of Microsoft products in the aisles of CompUSA even though the Linuxrulz web site says so
|
|
|
|
|
Is there a way to initialize a DLL in VB.Net? When you build a class library.
Apparently it's not OK to start a bonfire of Microsoft products in the aisles of CompUSA even though the Linuxrulz web site says so
|
|
|
|
|
That depends on what you mean by "initialize a DLL"??
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Sorry, I should have said that better. What I mean is, is there a way to run some method within the dll immediately after the dll is loaded into memory?
Apparently it's not OK to start a bonfire of Microsoft products in the aisles of CompUSA even though the Linuxrulz web site says so
|
|
|
|
|
How are you loading the dll? Are you using Reflection(Late binding) or creating a reference (early binding). If you are late binding use a default constructor otherwise with early bound objects put your method call in any of the constructors which are important.
Personally I like to use an interface with the desired method and call the method when I use reflection to late bind. I am not sure if this is what you are looking for but I hope it helps.
|
|
|
|
|
Thanks, I figured that is what I would have to do, I was just wondering if there was some built in event or something along those lines that would be fired when a dll was loaded into memory...My error handling class needs to initialize as soon as it is loaded into memory, but I dont think that is really going to be possible so what I did was to seperate it into its own dll, make it completely shared, build a sub Main for the startup project of my application, and initialize it there...then all of the other dll's in my project include a reference to the dll and it catches exceptions from them as well...here is a copy of my class if you are interested...It's basicly just an exception logger:
'NOTE: If running on a development machine, this will not work properly unless HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\DbgJITDebugLaunchSetting is set to 1
Imports System.Windows.Forms
Imports System.Data.SqlClient
Imports ZipsCommon
Public Class ErrorHandler
#Region " Variables "
Private Shared mHasBeenInited As Boolean = False
#End Region
#Region " Constructor Lockout "
Private Sub New()
End Sub
#End Region
#Region " Event Handler "
Private Shared Sub ThreadHandler(ByVal sender As Object, ByVal e As System.Threading.ThreadExceptionEventArgs)
LogException(e.Exception, True)
End Sub
Private Shared Sub UnhandledHandler(ByVal sender As Object, ByVal e As UnhandledExceptionEventArgs)
LogException(e.ExceptionObject, True)
End Sub
#End Region
#Region " Subs "
Public Shared Sub Init()
If mHasBeenInited Then Exit Sub
AddHandler Application.ThreadException, AddressOf ThreadHandler
AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf UnhandledHandler
mHasBeenInited = True
End Sub
Public Shared Sub LogException(ByVal ex As Exception)
LogException(ex, False)
End Sub
Private Shared Sub LogException(ByVal ex As Exception, ByVal wasUnhandled As Boolean)
Try
'NOTE: To avoid circular dependencys, all errors will be loged to the database at->SetupInfo.DBConnStr
Dim cmd As SqlCommand = New SqlCommand("NewError", New SqlConnection(SetupInfo.DBConnStr))
With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.AddWithValue("@StoreID", SetupInfo.StoreID)
.Parameters.AddWithValue("@ExMsg", ex.Message)
.Parameters.AddWithValue("@StckTrc", ex.StackTrace)
.Parameters.AddWithValue("@WasUnhandled", wasUnhandled)
.Connection.Open()
.ExecuteNonQuery()
.Connection.Close()
.Connection.Dispose()
.Dispose()
End With
Catch ex2 As Exception
End Try
End Sub
Public Shared Sub Dispose()
If Not mHasBeenInited Then Exit Sub
RemoveHandler Application.ThreadException, AddressOf ThreadHandler
RemoveHandler AppDomain.CurrentDomain.UnhandledException, AddressOf UnhandledHandler
mHasBeenInited = False
End Sub
#End Region
End Class
Apparently it's not OK to start a bonfire of Microsoft products in the aisles of CompUSA even though the Linuxrulz web site says so
|
|
|
|
|
Nevermind guys, I found the answer I needed here:
Clickety[^]
I wrote a class that should handle unhanded exceptions, but it is not working...below is the code. It is in a dll that I import into my project. I think the issue could be that the error handler is in the dll and not something In my current application, so maybe it is a thread issue? If you have any suggestions or if you know what the problem is, please let me know. Thanks.
Imports System.Windows.Forms
Imports System.Data.SqlClient
Imports ZipsCommon
Public Class ErrorHandler
#Region " Variables "
Private Shared mHasBeenInited As Boolean = False
#End Region
#Region " Constructor Lockout "
Private Sub New()
End Sub
#End Region
#Region " Event Handler "
Private Shared Sub TheHandler(ByVal sender As Object, ByVal e As System.Threading.ThreadExceptionEventArgs)
LogException(e.Exception, True)
End Sub
#End Region
#Region " Subs "
Public Shared Sub Init()
If mHasBeenInited Then Exit Sub
AddHandler Application.ThreadException, AddressOf TheHandler
mHasBeenInited = True
End Sub
Public Shared Sub LogException(ByVal ex As Exception)
If Not mHasBeenInited Then Init()
LogException(ex, False)
End Sub
Private Shared Sub LogException(ByVal ex As Exception, ByVal wasUnhandled As Boolean)
Try
If Not mHasBeenInited Then Init()
'NOTE: To avoid circular dependencys, all errors will be loged to the database at ->SetupInfo.DBConnStr
Dim cmd As SqlCommand = New SqlCommand("NewError", New SqlConnection(SetupInfo.DBConnStr))
With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.AddWithValue("@StoreID", SetupInfo.StoreID)
.Parameters.AddWithValue("@ExMsg", ex.Message)
.Parameters.AddWithValue("@StckTrc", ex.StackTrace)
.Parameters.AddWithValue("@WasUnhandled", wasUnhandled)
.Connection.Open()
.ExecuteNonQuery()
.Connection.Close()
.Connection.Dispose()
.Dispose()
End With
Catch ex2 As Exception
End Try
End Sub
Public Shared Sub Dispose()
If Not mHasBeenInited Then Exit Sub
RemoveHandler Application.ThreadException, AddressOf TheHandler
mHasBeenInited = False
End Sub
#End Region
End Class
-- modified at 18:58 Thursday 19th April, 2007
Apparently it's not OK to start a bonfire of Microsoft products in the aisles of CompUSA even though the Linuxrulz web site says so
|
|
|
|
|
I am building a windows app to that will keep track of customers, quotes, orders and so forth using VB in visual studio 2005.
I have a master-detail form that contains a Quoteheader and Quoteline datagridview that where the users can add products, price, number and so forth.
I have also created another form (product search) that enables users to easily filter and search for products to pick the product(s) they want to add to the quote using a checkbox that I added to each row in the grid. (The data for this datagridview is pulled from a seperate dataset based on a view that contains, among other things, the info I need to transfer to the quoteline datagridview).
Specifically I want to insert a new row in the Quoteline datagridview on the Quoteform where I automatically add the following field values (articleID, price per unit and costprice) from the product search datagridview to their respective column cells on the quoteline datagridview. It should insert a new row in the qoteline datagridview for each product that is selected using the checkbox on the product search form.
I would like some help and advice on how to best code this operation.
|
|
|
|
|
I'm assuming that your datagridview controls are datatable driven. If so, you can create a default view from the product search table while setting a rowfilter on the check box column. Then set the datasource table of the quoteline datagridview equal to this default view.
|
|
|
|
|
I'm not sure, but I don't think what u are suggesting is quite what i am looking for.
what i am looking for is the vb.net syntax for how to do something like this:
dim aricleid as integer
dim productname as string
dim productprice as string
select
articleid,
productname,
productprice
from productsearchform.datagridview
where checkboxcolumn.checked=true
insert into quoteline.datagridview
articleidcolumn,
productnamecolumn,
productpricecolumn
with values (get the declared values from above code)
articleid,
productname,
productprice
continue to next row until all rows on the on the productsearch datagrid that have been checked have been inserted as new rows in the quoteline datagridview.
Is there a good way to do this?
|
|
|
|
|
Assume for example,
productsearchform.datagridview.datasource = datatableproductsearchform
quoteline.datagridview.datasource = datatablequoteline
Try this approach:
datatableproductsearchform.defaultview.rowfilter = "checkboxcolumn = true"
datatablequoteline = datatableproductsearchform.defaultview.totable
Or this approach:
Add this code to productsearchform.datagridview selectedindexchanged event
if productsearchform.SelectedRow.Cells.Item(0).Text = true
dim datarownew as datarow
datarownew = datatablequoteline.newrow
'use the following code to populate the fields, one per field in datatablequoteline
datarownew.item("[field name]") = productsearchform.SelectedRow.Cells.Item(1).Text
datatablequoteline.rows.add(datatownew)
end if
|
|
|
|
|
Hi Dptalt,
The last approach seems to be what I have been looking for. I'll give it a shot later today. Appreciate your help.
best regards,
Hans
|
|
|
|
|
My form has a TabControl with 4 tabs. The user fills out information on each tab. When the user tries to change to a different tab I validate the information on that tab first. The validating code is in the TabControl.Leave event. If the information the user enters is not valid I have a messagebox popup that says the information needs to be corrected. If this occurs it still goes to the new tab the user clicked on. How can I code it so that it stays on the current tab until the information is valid? Can I cancel the event so that it does not go to the new tab?
|
|
|
|
|
In this event put your msgbox and validation routine call
Private Sub TabControl1_Selecting(ByVal sender As Object, ByVal e As System.Windows.Forms.TabControlCancelEventArgs) Handles TabControl1.Selecting
'validate
'msgbox
e.Cancel = True '<- ignores tab change event
End Sub
|
|
|
|