|
If "test" is an event handler, you should be using a delegate to handle the event in other forms. If it a method that provides some common functionality, it should be placed in a separate class file, something like "Common.vb" and should be placed there. There you can have it as an internal static or an internal method to call it in any of the forms in your application.
You can make the method internal in the MDI parent itself and access it in the child using Me.MDIParent property.
To access the variable number, you can make use of a internal/public property and can access it using me.MDIParent again.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
In Form1:
Public number As Integer
In Form2:
Form1.Test()
Debug.Writeline(Form1.number.ToString)
I don't speak Idiot - please talk slowly and clearly
'This space for rent'
Driven to the arms of Heineken by the wife
|
|
|
|
|
|
This is a graduation project and you're asking us for the code to solve a problem?? You don't really deserve to graduate then, do you?
If you can't dig around in your brain and write the code yourself, what good is your degree then?
|
|
|
|
|
Dave Kreskowiak wrote: a graduation project and you're asking us for the code to solve a problem?
Oh gawd, I go away for some time, and these types of posts still float around here?
Dave Kreskowiak wrote: If you can't dig around in your brain and write the code yourself, what good is your degree then?
Excellent point.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Notice the rush to serve up some code to you. Seriously if you looked through the forum your would run across this type of question regularly and they always get a negative response. Do your own work, as Dave said what good is serving up someone elses code as your graduation project. Thats called CHEATING.
You've thought of an idea (half the job) now do the research to find out how you can make it work. Excercise those little grey cells in there and try Google.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
it's not that i'm looking for the solution easily..i tried brainstorming for long bt got tired..!
i only need tips that will make me think easily..if ur not gonna help then why is this website available then..!
|
|
|
|
|
People here, generally, do not spoon feed. Also, you are doing a course that expects you to learn something. If you search the web and find some code and just copy paste it to pass, then there no use doing the course.
Here are a couple of things to think about:
1. How are you going to send the notification? Mail, popup, alarm etc?
2. What kind of application this is? Windows based, web based?
At a very high level, your application should work like this:
Any time something is sold, you will be updating the quantity in database. At the same time place check such that when the product quantity goes below a certain level send your notification.
In the end it is your project so you should be thinking about this. In case you get stuck during the project and have a specific question, post it here and and I am sure some one will show you the right way.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
yea i guess ur right...thx for the tips anyway...
|
|
|
|
|
I wasn't trying to give you a smart ass answer. I wasn't sure but I though you were just asking how to display the message. If you were asking how to do this project though it's like d@nish said, people will point you in the right direction or give you 1 or 2 lines of code but they aren't going to write your whole program for you.
|
|
|
|
|
MikeMarq wrote: I wasn't sure but I though you were just asking how to display the message.
4th year compsci student needs a tutorial on MessageBox.Show()? Ouch. Not much belief in the education system, huh?
|
|
|
|
|
I am a relatively new VBA user and this is my first post (formatted better).
I am using Excel 2002 sp3 with VBA (help shows VB 6.03 version 1024) on an XP sp3 machine.
I have a project with one workbook that has one form - frmRecordJob.
This form has a calendar control, a combo box, 2 listboxes, some labels, and 2 text boxes.
The 2 list boxes (lstCode1 and lstCode2) are in a frame.
lstCode2 was created by copy/paste from lstCode1.
Checking their properties shows them to be identical except for the tab indices and top properties.
The value and text properties are both empty, with no blanks in field.
Both listboxes get their row source set in the form initialization routine.
These listboxes are not changed in any project code other than the form initialize event.
If I close Excel, restart Excel, open the workbook, immediately start the VB editor, open and step through the form initialize procedure, the following occurs:
Private Sub UserForm_Initialize()
*** some irrelevant code left out here ***
With lstCode1
.RowSource = strRngBaseTable
End With HERE lstCode1.Value = ""
With lstCode2
.RowSource = strRngBaseTable
End With HERE lstCode2.Value = null
End Sub
Why are the 2 list box values be different at this point?
I don't know if they should be "" or null, but I would think they would be the same.
Would they normally be "" or null?
At the end of the initialize procedure the form is shown and the 2 list boxes do not have any values selected. This is correct.
The form has a command button on it. If this button is clicked (no other mouse or keyboard actions) the click event procedure shows the following.
Private Sub cmdOK_Click()
Dim lng01 As Long
Dim bValidateNewGroom() As Variant
ReDim aryGroomDataFlags(1 To 6) As Variant
'If no Code1 entered
If IsNull(lstCode1) Then 'HERE lstCode1 = "" as before
lstCode1.Value = "" 'This line is not executed (correct)
End If 'HERE lstCode1 = "" as before (correct)
'If no Code2 entered
If IsNull(lstCode2) Then 'HERE lstCode2 = null (as before)
lstCode2.Value = "" 'This line IS executed (correct)
End If 'HERE lstCode2 = null (should be "")
The following (next) statement blows up with runtime error 94
"Invalid use of null"
I think this is because lstCode2 is null
'If new job data is valid
aryGroomDataFlags = ValidateGroomData_
(calGroomDate.Value, _
cmbAnimalName.Value, _
lstCode1.Value, _
lstCode2.Value, _
txtExtra1Charge.Value, _
txtExtra2Charge.Value)
My questions:
Why would the 2 list boxes be initialized differently (1="",2=null) ?
Why after lstCode2 is set to "" it still shows its value as null?
|
|
|
|
|
Hi,
do not create a new thread, you could as well have edited the existing thread.
My answer there is still valid.
|
|
|
|
|
I am looking for how to reset my listbox to the first item, which is "blank". I am selecting answers to survey questions, and then copying and pasting them to another worksheet. I know how to do this in VB. What I want to also do, is reset the listbox's to the first item, which is simply Blank. I am using Excel 2007 with Vista.
The linked fill range is AG1:AG6, with AGI being Blank. The linked cell is C100.
I'm sure this is not a difficult thing to do, but i simply need some assistance in determing how best to get the listbox back to the blank position
Thank you very much
Marty
|
|
|
|
|
Hi,
this isn't clear.
if you want to change the content, work on ListBox.Items; that collection has a Clear() method.
if you want to scroll the ListBox, set ListBox.TopIndex
|
|
|
|
|
Normally when we using 'Appendtext' method of a text box, the text will append to end of existing text in the text box. But i want to know that is there method to append text to specific location of a text box. As a example i have two text boxes named text1 and text2. When i am typing in textbox1, the text will append to textbox2 as same time. Now i want to append this text to textbox2 to the specific location (to beginning or to middle or somewhere) not to end. I hope your kind reply and sorry for my bad english.
|
|
|
|
|
You need the String.Insert method.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
thank you d@nish for your fast reply. I have another question. when we change cursor location of a text box, how can I get cursor location as a number. As a example when i put cursor beginning of the text or any other location i want to get a value indicating cursor location.( When I put the cursor beginning of the text then the cursor location will be 0, and when I put the cursor end of the text then the cursor location will be length of the text)
|
|
|
|
|
There is a thing called documentation; you can retrieve it easily by entering the class name of interest and maybe the word MSDN into the Google search box. Read and learn, don't ask the world to spoon feed you.
|
|
|
|
|
hey, I found it. Thanks for your idea.
|
|
|
|
|
Good. Now discover the world, and come back when you have harder questions!
|
|
|
|
|
Hello,
I am facing with a strange problem when I read values from a dataset table. When I make a new row entry in to datatable ("Expenses"), I assumed that it would generate the RecordNumber (Primary Key) as it has already been defined in the original database table. The record number uses auto increment (seed= 100, and AutoIncrement value = 5). However, when a make a new row entry into dataset table, it doesn't produce a new record number but -1. Do I have to manually create a RecordNumber to use in dataset table?
When I tried to read from datatable and put the value into Listview, I realized that it puts explanation instead of RecordNumber into RecordNumber column in the Listview. If you know the solution, please let me know.
Regards.
WHERE DO I MAKE A MISTAKE?
Dim NewRow As BPRO.ExpensesRow = BPRO.Expenses.NewRow()
NewRow("CategoryNumber") = CInt(Category.SelectedValue)
NewRow("Currency") = Currency.SelectedItem
NewRow("PaidAs") = Paidas.SelectedItem
NewRow("DateRecorded") = DatePaid.Value.ToShortDateString
NewRow("Explanation") = Trim(Explanation.Text)
NewRow("Amount") = CDec(Amount.Text)
NewRow("CreditCardNumber") = CInt(Whichcreditcard.SelectedValue)
BPRO.Expenses.Rows.Add(NewRow)
ExpensesTableAdapter1.Insert(CInt(Category.SelectedValue), _
Currency.SelectedItem, _
Paidas.SelectedItem, _
DatePaid.Value.ToShortDateString, _
Trim(Explanation.Text), _
CDec(Amount.Text), _
CInt(Whichcreditcard.SelectedValue))
LI.Text = xrow("RecordNumber")
ListView1.Items.Add(LI)
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
JUNEYT wrote: it doesn't produce a new record number but -1.
New records get negative numbers because the dataset hasn't been written back to the database yet. The database always assigns the key values, not your code. Update the database with the changes being held in the dataset and your new records will get their keys will get updated with real values.
|
|
|
|
|
I am a relatively new VBA user and this is my first post.
I am using Excel 2002 sp3 with VBA (help show VB 6.03 version 1024 on an XP sp3 machine.
I have a project with one workbook that has one form - frmRecordJob.
This form has a calendar control, a combo box, 2 listboxes, some labels, and 2 text boxes.
The 2 list boxes (lstCode1 and lstCode2) are in a frame. lstCode2 was created by copy/paste from lstCode1.
Checking their properties shows them to be identical except for the tab indices and top properties.
Both get their row source set in the form initialization routine.
These listboxes are not changed in any project code other than the form initialize event.
If I close Excel, restart Excel, open the workbook, start the VB editor, open and step through the form initialize procedure, the following occurs:
Private Sub UserForm_Initialize()
*** some code here that does not reference the list boxes ***
*** HERE indicates this line is highlighted during debug ***
With lstCode1
.RowSource = strRngBaseTable
End With HERE lstCode1 value = ""
With lstCode2
.RowSource = strRngBaseTable
End With HERE lstCode2 = null
End Sub
Why would the 2 list box values be different at this point?
Would they normally be "" or null?
At the end of the initialize procedure the form is shown and the 2 list boxes do not have any values selected. This is correct.
The form has a command button on it. If this clicked without any changes made the click event shows the following.
Private Sub cmdOK_Click()
Dim lng01 As Long
Dim bValidateNewGroom() As Variant
ReDim aryGroomDataFlags(1 To 6) As Variant
'If no Code1 entered
If IsNull(lstCode1) Then HERE lstCode1 = "" as before
lstCode1.Value = "" This line is not executed (correct)
End If HERE lstCode1 = "" as before (correct)
'If no Code2 entered
If IsNull(lstCode2) Then HERE lstCode2 = null as before
lstCode2.Value = "" This line IS executed (correct)
End If HERE lstCode2 = null (should be "")
'If new job data is valid
aryGroomDataFlags = ValidateGroomData(calGroomDate.Value, _ HERE blows up with runtime error 94
cmbAnimalName.Value, _ "Invalid use of null"
lstCode1.Value, _ I think this is because lstCode2 is null
lstCode2.Value, _
txtExtra1Charge.Value, _
txtExtra2Charge.Value)
My questions:
Why would the 2 list boxes be initialized differently (1="",2=null) ?
Why after lstCode2 is set to "" it still shows its value as null?
|
|
|
|