|
frankiebaby2 wrote: Additional: I guess I have to "Call" my sub proceedure then yes?
Correct, calling a method is a gosub, it always returns. Goto exists within a method, but you cannot call a method and give it full control, it always comes back.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
Thanks again for you help by confirming the Call method Christian, just now trying to sort out the simple syntax for it.
Private Sub Textbox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Textbox1.TextChanged<br />
Call DataChange() 'Having troubles here<br />
End Sub
'Guessed to put "RuntimeTypeHandle" in here, but not sure what is required
Private Sub DataChange(ByVal sender As System.RuntimeTypeHandle)<br />
btnAccept.ForeColor = Color.Red<br />
<code>etc....
End Sub
-- modified at 20:15 Monday 10th September, 2007
|
|
|
|
|
There is no Call keyword, AFAIK. Your issue is that you need a RuntimeTypeHandle to pass in. If the param is called sender, then this is obviously an event, your best bet is to factor the code out, so that DataChange and Textbox1_TextChanged both call the same method. If you don't use the parameter, another approach is to pass Nothing as the parameter, but if the code uses 'sender', this will cause a null reference exception, as you're essentially saying - here's an object with no value.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
Thanks again for your speedy reply Christian.
I am so confussed. The RuntimeTypeHandle was just an attempt to put something there to make it work. I don't understand, so I'll just attempt to rephrase what I need.
When for example text is changed in Textbox1,2,3,4 or 5, I need a command, method or whatever to do the same proceedure.
I created the "DataChange" sub to try to pervent repeating the same command lines in each Textbox(x)_TextChanged.
My previous program language was a VERY long time ago, so I need to keep it simple. Sample code speaks to me the clearest I think.
Thanks
|
|
|
|
|
frankiebaby2 wrote: The RuntimeTypeHandle was just an attempt to put something there to make it work.
Where did you get it from ? What does it do ? If you never access the variable, remove it and all your problems are solved.
I'd love to give you more sample code, but I really don't know what you're after. A sender is usually an object, it was only the variable name that made me think this was something I'd just not seen before. So, if you don't use sender in your method, remove it from the parameters, and then the command
DataChange()
is all you need ( being VB, you may not even need brackets ).
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
Ok, how's this....
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged<br />
'Need code here to go and run the DataChanged Sub below.<br />
End Sub<br />
<br />
Private Sub DataChange()<br />
btnAccept.ForeColor = Color.Red<br />
btnAccept.Enabled = True<br />
btnNoteboard.Enabled = False<br />
btnLab.Enabled = False<br />
btnJobReg.Enabled = False<br />
btnSmplReg.Enabled = False<br />
btnBusiness.Enabled = False<br />
End Sub
Sorry, I know this must be so simple for you, but I am catching up slowly to VB.Net. I appreciate your patience.
It's OK I GOT IT!!! Thanks so much for your help
|
|
|
|
|
frankiebaby2 wrote: It's OK I GOT IT!!! Thanks so much for your help
*grin* Awesome. Glad to help out.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
how to insert a record in ms access
joe
|
|
|
|
|
You've created two accounts, to post the same question twice, when typing it verbatim into google would flood you with answers more detailed than you could hope to get from a forum reply ?
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
how to insert records in ms access
The email you supplied has already been registered. Please choose another.
No article notification email address was supplied. We'll use your login email instead (if possible).
|
|
|
|
|
edwin_manic wrote: how to insert records in ms access
Using what? (I assume you don't mean by opening the table in Access and typing the data in)
|
|
|
|
|
Hello all!
I've encountered a problem when I have have my drawings drawn onto a bitmap.
The problem comes when i repaint the bitmap. It seems that any text that i have is distorted (seems like an awful bolded text), while the charts and lines all looked fine.Certainly if I were to draw everything onto screen without saving onto a bitmap first, then the displayed text has no problem showing up perfectly.
So hmm, what could the problem be?
The font type,style or graphicsUnit?
'Display Text and Values<br />
strText = "(" & arrayTable(arrayLoc).estimated_StartDate & "," & arrayTable(arrayLoc).Duration & ")"<br />
<br />
grfx.DrawString(strText, New Font("VERDANA", 7.0, FontStyle.Regular, GraphicsUnit.Point), Brushes.Black, (x1 + bar_Width + line_Width), y1 + yCenter - 6)
Or the way i'm saving it into the bitmap?
Dim grfx As Graphics = pnl_Chart.CreateGraphics()<br />
grfx = Graphics.FromImage(new_snapshot)
Or the problem on the paint event?
e.Graphics.DrawImage(new_snapshot, 0, 0)
Anyway, I feel this is not the most efficient way for storing/displaying something but its what i've only managed, so any suggestions on performance issues?
Thanks in advance!
Regards,
Jensen
|
|
|
|
|
Are you performing some transformations, as in Graphics.ScaleTransform() and many others?
What is the size of your Bitmap?
jensenx wrote: Or the way i'm saving it into the bitmap?
You are not really saving to bitmap, you are drawing inside the Bitmap, aren't you?
You might consider showing the entire bitmap creation, graphics and drawing method,
as well as the Paint handler.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Yup, i'm drawing it into bitmap
Here goes,
Private Sub DrawBars_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles pnl_Chart.Paint<br />
e.Graphics.Clear(Color.White)<br />
<br />
If chart_NoChange = False Then<br />
chart_NoChange = True<br />
new_snapshot = New Bitmap(pnl_Chart.Size.Width, pnl_Chart.Size.Height, pnl_Chart.CreateGraphics())<br />
<br />
drawBarChart()<br />
<br />
e.Graphics.DrawImage(new_snapshot, 0, 0)<br />
e.Dispose()<br />
<br />
Else<br />
e.Graphics.DrawImage(new_snapshot, 0, 0)<br />
e.Dispose()<br />
End If<br />
<br />
End Sub<br />
<br />
Public Sub drawBarChart()<br />
<br />
Dim brush_Handle As Integer = 1<br />
Dim strText As String<br />
Dim clearForm As Boolean = True<br />
<br />
Dim grfx As Graphics = pnl_Chart.CreateGraphics()<br />
<br />
'TEST DRAW ON BITMAP<br />
grfx = Graphics.FromImage(new_snapshot)<br />
<br />
Dim yCenter As Integer = (bar_Height / 2)<br />
<br />
<br />
'Draws today's line<br />
If chk_ShowTodayLine.Checked = True Then<br />
Dim x As Integer = get_xLocation(Date.Today.Date) + (grid_Width / 2)<br />
grfx.DrawLine(Pens.Blue, x, 0, x, pnl_Chart.Height)<br />
End If<br />
<br />
'Draw project's end date<br />
If grid_EndDate <> "" Then<br />
Dim x As Integer = get_xLocation(grid_EndDate) + (grid_Width)<br />
grfx.DrawLine(Pens.Red, x, 0, x, pnl_Chart.Height)<br />
<br />
End If<br />
<br />
Dim arrayLoc As Integer = 0<br />
While arrayLoc <> grid_Task.Rows.Count<br />
<br />
'Normal chart from arraytable-----------------------------------------------------<br />
If arrayTable(arrayLoc).Duration <> 0 Then<br />
'Set values<br />
Dim x1 As Integer = arrayTable(arrayLoc).xLocation<br />
Dim y1 As Integer = arrayTable(arrayLoc).yLocation<br />
Dim bar_Width As Integer = (grid_Width * arrayTable(arrayLoc).Duration)<br />
<br />
'Draw Rectangle<br />
grfx.DrawRectangle(Pens.Black, New Rectangle(x1, y1, bar_Width, bar_Height))<br />
'Highlight selected<br />
If selectedRow = arrayLoc Then<br />
'Fill Rectangle<br />
grfx.FillRectangle(Brushes.Black, New Rectangle(x1 + 1, y1 + 1, bar_Width - 1, bar_Height - 1))<br />
Else<br />
'the +1 and -1 are there to display the rectangle nicely<br />
grfx.FillRectangle(objColorArray(brush_Handle), New Rectangle(x1 + 1, y1 + 1, bar_Width - 1, bar_Height - 1))<br />
<br />
End If<br />
'Display Text and Values<br />
strText = "(" & arrayTable(arrayLoc).estimated_StartDate & "," & arrayTable(arrayLoc).Duration & ")"<br />
grfx.DrawString(strText, New Font("VERDANA", 7.0, FontStyle.Regular, GraphicsUnit.Point), Brushes.Black, (x1 + bar_Width + line_Width), y1 + yCenter - 6)<br />
<br />
brush_Handle += 1<br />
'If goes more than 150 colors been used<br />
If brush_Handle > objColorArray.GetUpperBound(0) Then<br />
brush_Handle = 1<br />
End If<br />
Else<br />
'Those not assigned rows....<br />
End If<br />
'End Normal chart from arraytable--------------------------------------------------<br />
<br />
<br />
<br />
arrayLoc += 1<br />
End While<br />
<br />
<br />
grfx.Dispose()<br />
<br />
<br />
<br />
End Sub<br />
Sorry for the mess! I would gladly clarify parts of my code if it needs to be
|
|
|
|
|
Hi,
I am not sure what is causing the problem; here are some remarks:
1.
you call Dispose() on PaintEventArgs, which is wrong: you did not create that event, nor
did you call a method that creates it, so you should not dispose of it, it is not yours at all.
2.
you don't call Dispose() on new Font(...) in DrawString(...); here you did
ask for the creation and you don't Dispose(); that's a memory leak. If it's only one font
that you need regularly, you might want to create it once and keep it in a class member.
3.
you don't call Dispose() on pnl_Chart.CreateGraphics() in new Bitmap(...); here you did
ask for the creation and you don't Dispose(); that's a memory leak. A Graphics is a big
object, older Windows only can handle a few of them, so you really should dispose() of it.
4.
you explicitly specify GraphicsUnit.Point in new Font(...); although it seems correct,
I have never used it. Try omitting that argument. font sizes are in points by default.
Apart from these, I could not see anything wrong and causing the effects you described.
BTW: why do you show code in CODE tags? it would read much easier in PRE tags!
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi again!
Thx for your response. I've looked into those areas you have highlighted and made necessary changes.
One for instanc; instead of calling a new Font everytime, ive Dim verdanaFont as New Font ("VERDANA",7.0), is this right?
Cause im still having the same problem
I would appreciate if someone could write up a simple app to have the same concept of drawing the string into a bitmap then later painting the bitmap onto screen.
Oh and about using 'code' instead of 'pre', im still quite new around here. I've wanted to paste my codes in, and by looking at the formatting available below, the word code stands out, even more when its in red. Will use pre next time!
Thanks in advance!
Regards,
jensen
|
|
|
|
|
A quick alteration!
i've managed to solve the problem by writing the codes a lil differently but using the same concept....dont know why this new way works....
but anyhow
Cheers!
regards,
jensen
|
|
|
|
|
I'm having problems w/the following code. It doesn't seem to update my Access database. Thanks in advance for your help.
---
Option Explicit On
Imports System.Data
Imports System.Data.Oledb
Public Class frmAddCompany
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim strProvider As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Environment.CurrentDirectory & "\testDb.mdb"
Dim strSQL As String = _
"select * from company"
Dim myDbConn As OleDbConnection
Dim myDataAdapter As OleDbDataAdapter
Dim myDataSet As DataSet = New DataSet
Dim myDataTable As DataTable = New DataTable
myDbConn = New OleDbConnection(strProvider)
myDataAdapter = New OleDbDataAdapter(strSQL, myDbConn)
myDataAdapter.Fill(myDataSet, "Company")
myDataAdapter.Fill(myDataTable)
Dim myDataRow As DataRow = myDataTable.NewRow()
myDataRow("CompanyName") = "test123"
myDataTable.Rows.Add(myDataRow)
myDataSet.Tables("Company").AcceptChanges()
myDataAdapter.Update(myDataSet, "Company")
myDbConn.Close()
End Sub
End Class
|
|
|
|
|
Are you getting an error message? Could you please display it for us to see, if you are? Is the CompanyName the only column in the Company table? You don't seem to have any checks to make sure CompanyName is unique, this could lead to problems in the future.
For one thing, I don't think you need this statement:
myDataSet.Tables("Company").AcceptChanges()
Because it sets the changed flag on the rows in the table. Then when you do your update it doesn't think it's changed so it won't update it.
Hope this helps.
|
|
|
|
|
I put a Stop in my code so that I can view the contents of a local datatable. Is there a way to view the data in a datatable in a browse window, like an excel spread sheet allowing you to see all rows and columns at once?
|
|
|
|
|
I'll assume by Stop you mean a breakpoint...and if you have visual studio 2005 then it is pretty simple. All you have to do is set your breakpoint to stop sometime after your datatable has been filled, when it hits the breakpoint highlight the table name in your code and then hover your mouse over it. When a little icon appears that has a magnify glass, click on it. A popup will open that displays your data in a nice grid. Another way is to highlight the table name, right click and select QuickWatch. There you can click on the magnify glass icon at the top of the list of properties to look through. If you do not have visual studio 2005 I don't know of a nice way to view the data, short of writing some code to output it to a csv file to view in excel.
|
|
|
|
|
Hi does anyone know if there are problems with microsoft at the moment. all of a sudden when I enter the dataset configuation I'm getting thrown out and now it's even happening when I try and edit the dataset. various prompts including "microsoft has come encountered a problem and needs to close.
I've checked the problem and seems to be APPCRASH.
Can anyone help me please?
Nala
|
|
|
|
|
hi everyone,
i have a listbox which contain some item .now i want to change the content of selected item with new string as shown below
lstCaptionStructure.SelectedItem.ToString.Replace(lstCaptionStructure.SelectedItem.ToString, NewString)'lstCaptionStructure is list box
but above code does not work.can any body tell where i am wrong or how can we change the some or full part of selected item with other string ?
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
Hi,
if you have a collection of things and want to replace one of those things, you must
operate on the collection, hence something along the lines of:
lstCaptioStructure.Items(lstCaptioStructure.SelectedIndex)=NewString
Items is the collection here.
BTW this code would bomb if nothing is selected (as would your code)
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
thanks luc ,
its work
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|