I have an MS Access project which I am developing. Everything was good until I clicked the Compact and Repair Database, now every time my app hit line of code start from here Form_PersonalInfoPanel.cmboGender.Enabled = True from this method:
Public Sub setEmployeeForms(flag As Integer)
If flag = 0 Then
...
Else
Form_EmployeePanel.txtFullName.Enabled = True
Form_EmployeePanel.txtFullNameAr.Enabled = True
Form_EmployeePanel.cmbPcn.Enabled = True
Form_EmployeePanel.cmboDepartment.Enabled = True
Form_EmployeePanel.cmboJob.Enabled = True
Form_PersonalInfoPanel.cmboGender.Enabled = True
Form_PersonalInfoPanel.cmboMaritalStatus.Enabled = True
Form_PersonalInfoPanel.cmboNationality.Enabled = True
Form_PersonalInfoPanel.txtDob.Enabled = True
Form_PersonalInfoPanel.txtEmail.Enabled = True
Form_PersonalInfoPanel.txtMobile.Enabled = True
End If
End Sub
It now giving me:
Run-Time error '7':
Out of Memory
In the Debug mode, it says: <Object variable or With block variable not set> As for this one Form_EmployeePanel.cmboJob.Enabled = True, it works fine. My project is only 3.476 MB and I already deleted all files in my temporary folder.
Any help is much appreciated.
Related
I am completely new in Delegate and BeginInvoke . I have a project which is written as Win form app (Vb) and now I have to change it in Web asp.net and I really dont know how I can do that:
More about my project:
when I click on run button, my project runs and it caculates some data and it shows results in some textboxes till it finished . At the End the button save data enabled in order to save Results:
See it in action:
How the Project work
Run Button Function :
e.Run.Enabled = False
Me.Run.Text = "Please wait ..."
Me.simphony.Enabled = False
Me.access.Enabled = False
Me.optimizationEngineField = New OptimizationEngine(economyImportance:=0.5,
simphonyAnalysisModel:=Me.simphonyAnalysisEngine)
Dim tempThread As New Threading.Thread(Sub()
Me.bestSolutionField = Me.optimizationEngineField.StartOptimization(percentErrorTermination:=True,
maxIteration:=CInt(Me.TextBoxMaxIteration.Text),
percentError:=CDbl(Me.TextBoxAccuracy.Text))
End Sub)
tempThread.Start()
Me.TextBoxAccuracy.Enabled = False
Me.TextBoxMaxIteration.Enabled = False
Me.OptimizationStatusUpdate()
<br>
Optimization
<br>
Private Sub OptimizationStatusUpdate()
Dim tempThread As New Threading.Thread(Sub()
Dim attempt As Integer = 0
Dim firstRun As Boolean = True
While True
If Me.optimizationEngineField.IsRunning Then
firstRun = False
Me.BeginInvoke(Sub()
Me.TextBoxStatus.Text = Me.optimizationEngineField.Status
Me.TextBoxIsRunning.Text = Me.optimizationEngineField.IsRunning
Me.TextBoxIterationNumber.Text = Me.optimizationEngineField.IterationNumber
Me.TextBoxPercentError.Text = Me.optimizationEngineField.PercentError
Me.TextBoxActiveAntCount.Text = Me.optimizationEngineField.ActiveAntCount
Me.TextBoxAggregatedAntCount.Text = Me.optimizationEngineField.aggregatedAntCount
End Sub)
Else
If Not Me.optimizationEngineField.IsRunning And firstRun = False Then
attempt = attempt + 1
End If
If attempt >= 5 Then
Exit While
End If
End If
Threading.Thread.Sleep(1000)
End While
Me.BeginInvoke(Sub()
Me.ButtonSaveResults.Text = "Save Results"
Me.ButtonSaveResults.Enabled = True
Me.TextBoxIsRunning.Text = "False"
Me.Run.Enabled = True
Me.Run.Text = "Run"
Me.simphony.Enabled = True
Me.access.Enabled = True
End Sub)
End Sub)
tempThread.Start()
End Sub
<br>
I searched a lot in net and
First of all : all pages approximately have been written for win apps and they are not for web , If I am not wrong and secondly : I Try to convert those codes from C# to VB and got some errors
How can I change Optimization Code to run on Web ?
Thanks
So I am using Visual Basic to create a windows form application. I have buttons on the side to select a table like this. When the 'bookings' button is pressed, the user it taken to a form that looks like this. I need the following code to run every time the form is shown (the form is hidden shown multiple times). I put the below code inside both the form load and the form shown actions and both of them will only run the code on the first time. The code isn't really relevant, I just need to know how I can make this run every time the form is shown, not just once. The only other way I have thought about which works is to make the code run every second which is just unnecessary and a waste of processing power. Also, if I wanted another action to run after this, the action that occurs every second will take priority.
Private Sub Form2_Shown(sender As Object, e As EventArgs) Handles Me.Shown
If GlobalVariables.GlobalFlag = "1" Then
Table1Sleep.Visible = False
Table1Selected.Visible = True
Table1Selected.BringToFront()
table1text.BringToFront()
table1textdesc.BringToFront()
ElseIf GlobalVariables.GlobalFlag = "2" Then
Table2Sleep.Visible = False
Table2Selected.Visible = True
Table2Selected.BringToFront()
table2textdesc.BringToFront()
table2text.BringToFront()
ElseIf GlobalVariables.GlobalFlag = "3" Then
Table3Sleep.Visible = False
Table3Selected.Visible = True
Table3Selected.BringToFront()
table3text.BringToFront()
table3textdesc.BringToFront()
ElseIf GlobalVariables.GlobalFlag = "4" Then
Table4Selected.Visible = True
Table4Selected.BringToFront()
tabel4text.BringToFront()
table4textdesc.BringToFront()
table4sleep.Visible = False
ElseIf GlobalVariables.GlobalFlag = "5" Then
Table5Selected.Visible = True
table5sleep.Visible = False
Table5Selected.BringToFront()
table5text.BringToFront()
table5textdesc.BringToFront()
ElseIf GlobalVariables.GlobalFlag = "6" Then
table6sleep.Visible = False
Table6Selected.Visible = True
Table6Selected.BringToFront()
table6text.BringToFront()
table6textdesc.BringToFront()
Else
MessageBox.Show("Something went wrong. When you press 'OK', you will be taken back to the Main Menu.")
MainMenuForm.Show()
Me.Close()
End If
End Sub
Thanks :)
I am a newbie in visual basic, when i tried to run this code,the above error pops up.I have declared an user defined function named initiative but for no reason the error pops up.
Private Sub initiate()
For i = 0 To 2
COURSE(i).Value = False
SEM(i).Value = False
If i <> 2 Then
ODDEVEN(i).Value = False
End If
Any help is appreciated.
so i have this code
local player = game.Players.LocalPlayer
local unitFrame = script.Parent
local buttona = unitFrame.buttonA
local sprinting = true
unitFrame.Title.Text = "Perks"
local function onButtonAClick()
unitFrame.Title.Text = "perks"
end
local function sprintButton()
if sprinting == false then
sprinting = true
player.Character.Humanoid.WalkSpeed = 20
unitFrame.buttonA.Text = "strinting"
end
if sprinting == true then
sprinting = false
player.Character.Humanoid.WalkSpeed = 16
unitFrame.buttonA.Text = "walking"
end
end
buttona.MouseButton1Click:connect(sprintButton)
what i am trying to do is make a sprinting toggle program. The only problem is that it will work once then not work at all. i can click it and it changes the text then when i click it again it does nothing. i want it to be able to work every time you press it.
In the function you test 2 if statements. If sprinting is false, and if it it is true.
The key to understanding your problem is that your if statements counteract eachother.
Let's walk through this, first it detects if it's false. No, sprinting is not false. Then if checks if it's true. It is! So it sets it to false.
Great so far, right? Well here's your problem. When you try it again, sprinting is false. So the first if statement is run, and it sets it to true. But then, ANOTHER if statement is run immediately after. Since it's now true, this runs, setting it to false. It appears nothing happened.
Your solution? Take out the end to the first if statement, and replace the second if to an elseif. This way once one statement evaluated to true, it won't evaluate the next.
Your logic is not correct. As warspyking said, you have an issue with your conditionals. Fix this by adding an elseif statement instead.
local function sprintButton()
if not sprinting then
sprinting = true
player.Character.Humanoid.WalkSpeed = 20
unitFrame.buttonA.Text = "sprinting"
elseif sprinting then
sprinting = false
player.Character.Humanoid.WalkSpeed = 16
unitFrame.buttonA.Text = "walking"
end
end
I am developing a quality control system for my company, and I i want to connect it to a label printer, which is already taken care off, the problem now is with the button itself.
I want the print label button to only be enabled and visible after the whole check was made, what i've got now is this:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Button_label.Visible = False
Button_label.Enabled = False
End Sub
Private Sub Motor_OK_Change()
Dim ok As Boolean
ok = Motor_OK.Value
If ok = 1 Then
Button_label.Visible = True
Button_label.Enabled = True
End If
End Sub
It does work on conceiling the button, but it fails when trying to enable it again and making it visible upon making the check. It's important to refer that I have tried using If ok = True instead of If ok= 1, I dont know how important that is.
Thanks
You are not testing for both conditions (ok=0), perhaps the following will work:
Replace:
If ok = 1 Then
Button_label.Visible = True
Button_label.Enabled = True
End If
With:
Button_label.Visible = ok
Button_label.Enabled = ok
New Solution:
Instead of using the Form Before_Update event, use Form_Current event. If there is only 1 record, you can also use the Form_Load event. I would also suggest that you remove the Visible property and use only the Enabled one so users can see their is print functionality.
Private Sub Form_Current()
'button_Label.Visible = False
button_Label.Enabled = False
End Sub
Instead of using the Motor_OK Before_Updateevent, use After_Update event
Private Sub Motor_OK_AfterUpdate()
Dim ok As Boolean ' defaults to False
If IsNumeric(Motor_OK.Value) Then ok = True ' remove this statement if Motor_OM is
' alpha numeric.
If Not IsNull(Motor_OK.Value) Then ok = True ' otherwise following statement
' to avoid NULL error
'button_Label.Visible = ok
button_Label.Enabled = ok
End Sub
Let me know if I can be of further help.