|
you can do something like this to put the controls in the frame.
Dim i As Integer
Set Check1(0).Container = Frame1
Check1(0).Top = 10
Check1(0).Left = 10
For i = 1 To 10
Load Check1(i)
Set Check1(i).Container = Frame1
Check1(i).Left = 10
Check1(i).Top = Check1(i - 1).Top + Check1(i).Height
Check1(i).Visible = True
Next
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
nlarson11...'Set DynChkBx0(0).Container = Frame3'---perfect, that was exactly what i was looking for. Thank You!
|
|
|
|
|
Would anyone be kind enough to assist me with an issue i am having binding the user input through Radio buttons to a field (ExemptStatus) in my access database?
Dim grbExemptStatus As String
'declare radio buttons for Exempt values
If radNonExempt.Checked = True Then
grbExemptStatus = "Non Exempt"
End If
If radExempt.Checked = True Then
grbExemptStatus = "Exempt"
End If
On my User Form, I have a "Exempt" & "NonExempt" within a groupbox called "Exempt Status". I would like the user selection to be passed to a my access database; tblEmployee; fieldname = ExemptStatus. I have tried user Select case as well as If checked = true, but none of that is producing the desired result. Instead the value passed to my table is "exempt status?. Please help! TIA
modified on Tuesday, February 19, 2008 12:27 PM
|
|
|
|
|
You're not making the problem very clear to me, but i think you need code like:
Dim ValueToPass as String
if ExemptRadiobutton.Checked = True then ValueToPass = "Exempt"
if NonExemptRadiobutton.Checked = True then ValueToPass = "NonExempt"
Then send ValueToPass to your dataset.
Does this help?
|
|
|
|
|
Sorry, I didnt make the issue clearer. The code i used is exactly as you suggested, but I am not getting the desired result. Instead of getting the values "Non Exempt" or "Exempt", I get "Exempt Status" which is the text value of the groupbox.
'declare radio buttons for Exempt values
If radNonExempt.Checked = True Then
grbExemptStatus = "Non Exempt"
End If
If radExempt.Checked = True Then
grbExemptStatus = "Exempt"
End If
strEmployee = "INSERT INTO tblEmployees(" & _
"EmployeeNumber, FirstName, LastName, " & _
"HireDate, ExemptStatus, " & _
"Title, BaseSalary) VALUES('" & _
txtEmployeeNumber.Text & "', '" & txtFirstName.Text & _
"', '" & txtLastName.Text & "', '" & _
dtpHireDate.Value.ToString("MM/dd/yyyy") & "', '" & _
grbExemptStatus & "', '" & _
txtTitle.Text & "', '" & txtBaseSalary.Text & "')"
|
|
|
|
|
You have somewhere:
Dim grbExemptStatus as string = ""
and yet...
Console.writeline (grbExemptStatus) produces "exemptstatus"?
If so, I'm not sure what's going on.
|
|
|
|
|
Great!
Your last response provided the clue. Its now working.
Instead of:
Dim grbExemptStatus as string = ""
I had
Dim grbExemptStatus as string
By omitting the = "", it would simply pass the text name to the database instaed of the underlying value.
Thanks a bunch!
|
|
|
|
|
I created a Windows app in vb that searches a database and returns counts that are displayed in a word document. Well, I can run the application just fine under my profile on my pc, but if I run it from another profile on my own box (a standard user) or if I run it under the admin account on my test box, I get the Object reference not set to an instance of an object error.
Now I can’t see just where to error lies because, like I said it runs fine for me. Any ideas?
|
|
|
|
|
Something you haven't counted on is happening, obviously. You need to put some kind of error trapping into your .exe which will help you see where the error is on the other accounts and machines. There were some posts on this late last week on this site.
|
|
|
|
|
Okay, I did that and the clearer error is poining to what I guess is a call to one of my functions called count.
Here is the error that is coming up now:
System.NullReferenceException: Object reference not set to an instance of an object.
at Form1.count (String search, string startDate, string endDate)
at Form1.Button1_Click(Object sender, EventArgs e)
|
|
|
|
|
OK, well my guess is that one or more of your variables (search, startdate, or enddate) aren't instantiated.
|
|
|
|
|
Where would I do that at? In my function call or at Public Function count (byval search as string, byval startDate as string, byval endDate as string) as interger ?
|
|
|
|
|
Honestly, it's hard for me to tell, but the error seems to me to be occuring because the arguments you are passing to your function are not appropriately defined.
|
|
|
|
|
But why would it work under my profile?
|
|
|
|
|
Without seeing the code in your count method in Form1, it's impossible to tell you where the problem is. What we can tell you is that you tried to set a property or call a method on an object that is Nothing , or null in C#.
You probably retrieved an object, or a collection of objects, from somewhere and tried to use it without checking to see if an object was actually returned.
|
|
|
|
|
Well, here is my code for the count function:
Public Function count(ByVal search As String, ByVal startDate As String, ByVal endDate As String) As Integer<br />
Dim number As Integer<br />
Dim pubs As New SqlConnection(ConfigurationManager.ConnectionStrings("WIA_Report_Builder.My.MySettings.wiaConnectionString").ConnectionString)<br />
'pubs = ConfigurationManager.ConnectionStrings("wiaconnectionstring")<br />
'pubs.ConnectionString = ConfigurationManager.ConnectionStrings("WIA_Report_Builder.My.MySettings.wiaConnectionString").ConnectionString<br />
Dim connection As DbConnection = New SqlConnection()<br />
connection.ConnectionString = pubs.ConnectionString<br />
Dim cmd As DbCommand = connection.CreateCommand()<br />
cmd.CommandType = CommandType.Text<br />
Select Case search<br />
Case "TotalAdultPart"<br />
cmd.CommandText = "Select Count (*) from Demographics where AgeatEnroll >= 22"<br />
Try<br />
connection.Open()<br />
number = cmd.ExecuteScalar<br />
<br />
Catch ex As Exception<br />
Finally<br />
connection.Close()<br />
End Try<br />
....<br />
<br />
End Select<br />
Return number<br />
<br />
end function<br />
|
|
|
|
|
Stepping through the code line by line will tell you where the error is. All you have to do is set a breakpoint on the first line in the method code, then run your app. The debugger will stop the code when it hits the breakpoint. Then all you have to do is single-step until you reach the error.
Aptiva Dave wrote: Dim pubs As New SqlConnection(ConfigurationManager.ConnectionStrings("WIA_Report_Builder.My.MySettings.wiaConnectionString").ConnectionString)
The most obious failure here that can cause the error you're seeing is that ConfigurationManager.ConnectionStrings("WIA_Report_Builder.My.MySettings.wiaConnectionString") may have returned Nothing, on which you're trying to retrieve the value of the ConnectionString property.
From the looks of things, you're having problems retrieving the connection string from a configuration file, correct??
Also, you've (tried to) created a couple of SqlConnection objects. You only need one.
|
|
|
|
|
The problem I have using a break point and debugging that way is that I can get the program to run on my profile of my machine by just running the exe outside of vs 2005.
I don't believe that the issue is from getting to the connection string, but where do you see the multiple SqlConnection objects?
|
|
|
|
|
One possibility is to have your .exe program write a line to a text file after every couple of lines of code in the area where you think the problem is. Then you can see what the last line written was -- you know the error is after that, but before the next line write.
Also perhaps try simply writing the values of the variables in question to a file during the run and see what gets written.
These techniques have helped me in the past.
|
|
|
|
|
That sounds like a good idea. Don't know why I didn't think to do that. Guess I frustrated a bit with it not working and with all of my other help desk calls today.
Anyways, I'll try that when I get back to work tomorrow. Thanks
|
|
|
|
|
Then create another user on your machine and try it.
Better yet, get VMWare or Microsoft's Virtual PC's, install an O/S on it, then your app, and try it again.
|
|
|
|
|
I want to be able to modify a control on my mainform (Form1) from a backgroundworker on Form2. If I first open Form2 I can make it happen by calling the BGW from the button on Form2. However, I cannot call the BGW on Form2 directly from Form1. I don't see why not.
Thanks!
Public Class Form2
Private Delegate Sub SetTextBoxTextDelegate(ByVal text As String)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.BackgroundWorker1.RunWorkerAsync()
End Sub '
Private Sub SetTextBoxText(ByVal text As String)
Form1.TextBox1.Text = text
End Sub
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As
System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Me.Invoke(New SetTextBoxTextDelegate(AddressOf SetTextBoxText), "Set this text")
End Sub
End Class
|
|
|
|
|
No one can help me??
|
|
|
|
|
Patience.
You shouldn't be updating Form1 controls from Form2 at all. Form2 would be unable to exist without an instance of Form1 if you did. This violates encapsulation and OOP principles.
Form2 should be exposing events that Form1 can subscribe to, where then, Form1 can update it's own controls without Form2 knowing anything about it.
|
|
|
|
|
OK, that helps.
BGW.reportprogress is what I need I think.
Thanks
|
|
|
|