VS 2008 Calling Form Controls From Module?
Aug 25, 2009
I have a Sub Routine in a module to iterate controls on a form. I get an error about an instance of the object not created.I have declared the object and set it to the form (ModelsBox = Me). I have done this between two forms previously. Is there something fundamental that I am missing. Is this where the "Friend Shared" comes into play?
[Code]...
View 2 Replies
ADVERTISEMENT
Jun 10, 2011
I'm writing a program in vb.net 2003 and have come up with a problem.
I have a sub SettingsSave() in a module.
Public Sub SettingsSave()
Dim frmSaveSettings As New frmSettings
MsgBox frmSaveSettings.txtName.Value 'for testing purposes
SaveSetting("MyApp", "configs", "Name",frmSaveSettings.txtName.Value)
SaveSetting("MyApp", "configs", "Pass",frmSaveSettings.txtPass.Value)
End Sub
I have a form frmSettings, which has a button btnSave. When the button is clicked, SettingsSave() is called.The problem is, if btnSave is clicked, then either of the two textbox values are changed, then btnSave is clicked again, the SettingsSave() sub still returns the 'old' values (from the first time the save button was clicked).How do I clear the old values from memory? I've tried adding frmSaveSettings = Nothing, and frmSaveSettings.Close at the end of the sub SettingsSave().
View 5 Replies
Apr 5, 2010
I am using VB2008 In the Form1, i have coded
Public Function getText(ByRef ctlName As String) As String
getText = Mfg.get_TextMatrix(Mfg.Row,Mfg.Col
[Code]...
View 5 Replies
Apr 23, 2011
How do I do something like this.[code]...
This is inside the Module separate from Form1 class as you can see right off the bat it's not a class and there is no reference to Form1.. how do I access Form1 without passing reference to make factory modules work like this.
View 1 Replies
Sep 16, 2011
I have a form called form1 which has a thread that runs a sub from a module.[code]...
Well from the module, there's a part where I have to update controls on the form1. Whenever I try doing it, it updates the value, but not the design. For example I write a delegate which makes label1.text = "111", while debugging, label1.text becomes 111, but it does not show it updated on the form design, it just stays at its default value.
View 4 Replies
May 13, 2009
I have a module1.vb that contains a public sub, for example
Public Sub LogEvent(ByVal strIn As String)
Dim objLogFile As Object
objLogFile = frmEventLog.txtLog
[code].....
View 15 Replies
Sep 24, 2010
I have an 100 aspx files with one module file for code. All these aspx files have the same backend function, so i created on public module for all these files to access. These files are in the same folder. But for some reason the aspx files cannot access the function from that module.
mod1.vb Code (.vb file)
Public Module Allinone
Sub Allinone_Load(ByRef Page As Web.UI.Page)
[Code]....
I am at a roadblock of why the aspx files wont read this module? Also all these files are in the same directory
View 1 Replies
Sep 29, 2009
I have a console application consisting of two modules. One module named "quote" is the main module for the application. Another module named "common" contains commonly used functions and subroutines that are shared between multiple applications.
In the "common" module is a function named "quote". If I attempt to call the "quote" function from the module named "quote", then I get the following error: Error 1 'quote' is a type and cannot be used as an expression. However, if I copy the quote function from the "common" module to the "quote" module, then I no longer receive this error.
There shouldn't be an issue with calling a function that happens to have the same name as a module, but only when that function is located in a different module.
View 2 Replies
Aug 6, 2011
I would love to use the following procedure to set the Title, keywords etc. of my pages, in a module.
Public Shared Sub SetTitle(ByVal Heading As String, ByVal Keywords As String())
Dim myMaster As Masterpage = DirectCast(Me.Master, Masterpage)
If Request.QueryString("lng") = "es" Then
[Code]....
The problem is that i get two errors.
At Me.Master i get the 'Me' is valid only within an instance method. error and at
If Request... i get the error
Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.
So how do i fix these? I would like to have that procedure in a common place and not in every page.
View 1 Replies
Jun 1, 2009
I have been given an ASP.Net assignment at work because I had taken a few courses a couple of years ago. Currently, there are no ASP.Net programmers for me to ask here and I have searched several places (including Pro ASP Net book) to find a solution but have come up empty handed.
I have a class named spErrors which takes the values passed to it. Values passed include the offending page,function/sub, and other values and stores them in property values, then calls Response.Redirect("Errors.aspx") from the page's code behind page. In Errors.aspx, the values of the error/exception trapped in the Catch statement are displayed. This works fine from a web form. My question is, how do I call a web page from a class module?
Each class module has the ErrorHandler() procedure that passes these values to the class object. In the class, there is a Write Only property named Redirect and a method called Execute() which is used to display the error page if the error occurs in another class module. Since Response.Redirect() does not work in a class module, what namespace is needed in order for this to work?
Here is the code I'm using.
In the Catch block.
Catch ex As Exception
Err.Description = ex.Message
ErrorHandler(Err, "function name")
[code]....
View 2 Replies
Dec 15, 2011
I am developing a VB net application with lots of TextBox. I need to call a module everytime any of the textbox gets focus. I dont want to write code in every textbox gotfocus event, but a generic code which will call the module everytime any textbox gets focus.
View 6 Replies
May 25, 2012
I have an application (app.exe) that has a VB Module in its source code (Module1). The module has a function called Function1. I need to call this function from another application. The module is not marked as public, so adding a reference to app.exe won't work. I'm trying to use reflection (Assembly.LoadFrom()) but unless I'm way off base, the module would have to be a class in order for me to get an instance of it.
Please nobody ask me "what have you tried?" I tried a million different things and let's just say "none of them work." So I'm looking for someone that has specific experience with doing exactly what I'm trying to do. If you don't have that experience, please move on to the next question and ignore mine.
View 1 Replies
Jun 7, 2009
I'm making a simple window that bounces around the screen (no reason, just for fun). I can make it work when the moving code is in a Timer_Tick event in the form, but now that I try to move it out to a module, it won't work. Here's what I have:
[Code]....
I try to call it with Bounce(Me) but the form doesn't move. I added a Debug.WriteLine(form.Location) at the end of the sub, and it shows that the location is not changing.
View 7 Replies
May 4, 2009
I have a project that calls for just a ton of forms and I'd like them all centered on screen. Any way to call this in a module? Just trying to minimize the code necessary for each form. This is the basic centering I use now, only it's in each form_load.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim xLoc As Integer = (Screen.PrimaryScreen.Bounds.Width - Me.Width) 2
Dim yLoc As Integer = (Screen.PrimaryScreen.Bounds.Height - Me.Height) 2
Me.Location = New Point(xLoc, yLoc)
End Sub
View 3 Replies
Dec 16, 2010
I've been coding a Windows applicaton for the past seven months but there aren't a lot of "windows" in the application so I have a question on getting and returning data from forms. I display a form and the user makes a listbox selection then presses Ok. Normally I can proceed from there (in a class module) with values from the config file, but sometimes his selection will require me to ask for more information. So I want the class to display a form, pass control to it, then when the user hits OK on this form, return to the class. What is happening is the class continues with all its inline code and function calls and doesn't show the form until the end of its current function.
Dim flClientInputFile As New CFile
Dim flPreparedOutputFile As New CFile
Dim lRecordCount As Long
Dim sProcessing As String
Dim sTest As String
Dim frmAbc As New frmAbc
frmAbc.Show()
frmAbc.Activate()
x()
When I run and step through this code, I find I'm in x() before I even saw the form. x() needs the data the user has entered on frmAbc in order to continue.
View 2 Replies
Dec 6, 2009
I have a simple, but important question: How can I raise events of my form1 on another module/form?My form tempalte is crowded with events (50 of them contextmenustrip events)How can I place those events on another form/module to clean it up a little?
View 7 Replies
May 25, 2010
I have 2 forms FORM 1 and 2 i got this code in form 1
vb.net
Private Sub starauto_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles starauto.Click
form2.Button1.Value = True
form2.Button1_Click()
End Sub
but both examples give me an error
error 1.- 'Value' is not a member of 'System.Windows.Forms.Button'.C:Documents and SettingsleijaiMy DocumentsVisual Studio 2008ProjectsIp On or OffIp On or Offform1.vb239Ip On or Off
Error 2.- Error3Argument not specified for parameter 'sender' of 'Public Sub Button1_Click(sender As Object, e As System.EventArgs)'.C:Documents and SettingsleijaiMy DocumentsVisual Studio 2008ProjectsIp On or OffIp On or Offform1.vb249Ip On or Off
error 3.- Error2Argument not specified for parameter 'e' of 'Public Sub Button1_Click(sender As Object, e As System.EventArgs)'.C:Documents and SettingsleijaiMy DocumentsVisual Studio 2008ProjectsIp On or OffIp On or Offform1.vb249Ip On or Off
View 6 Replies
Aug 4, 2009
For some reason, a certain Form in my project will change it's size all on it's own right after I call it. It's usually with small forms in the one I'm having a problem with is 95x25 pixels. The only thing on it is a Label with some text in the middle and this code
Public Class MessageForm
Private Time As Integer = 25
Private Sub fadeTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles fadeTimer.Tick
Time -= 1
[Code] .....
As you can see the Form is meant to be a small pop-up that disappears on its own, like a balloon tip. Anyways I just added it to my project 5 minutes ago and as soon as I tested it out by displaying it with Form.Show(), it randomly changed to 123 by something else during runtime. I checked all the Form properties for any kind of resize properties and only found AutoScaleMode which was set on font, but set on None made no difference. Like I said I just added this form and have no code affecting it whatsoever in my entire project except for Form.Show and the code on that form. For the moment I'm just resizing the form on it's own Load event, and that seems to work, but I'd like to know what is causing this random form resize.
View 2 Replies
Mar 11, 2010
I have login form as start up form and i call Form1 after successful validation and in Form1, i have close button on click of Close i would like to reset username and password fields on loginform to null. If i add code in form1 below i get exception Dim fmLogin As New LogInForm
An unhandled exception of type 'System.StackOverflowException' occurred in System.Windows.Forms.dll
Make sure you do not have an infinite loop or infinite recursion
I get above on LoginForm below statement Dim fmMain As New Form1
How to take care of this problem
View 1 Replies
Nov 3, 2009
Q1: How can i make it so that my window that i want to show as a drop down does not appear to take the focus off the main form that is calling it?
Q2: The form that is dropping down has the FormBorderStyle Property set to None - thus the window does not have a drop down shadow - how can I make the popup window have a shadow?
View 1 Replies
Aug 9, 2010
I have combobox and I was wondering how do I call one of its events, for example,MyComboBox5_SelectedIndexChanged. I have no idea what to put in for its sender and e arguments.In other words; how do I complete the following statement
View 4 Replies
Dec 20, 2010
I have a form with MenuStrip, ToolStrip & StatusStrip. Placed a panel with a 5000 x 7000px image and scroll bars are on form and scroll the image fine. Problem is that all controls appear to have changed size to size of image and also scroll with it horizontally. When scrolling vertically, the image covers up the menu and tool strips. How I can keep the controls on top so they don't attach to the image in the panel?
View 2 Replies
Oct 8, 2010
I have Winforms application that holds dozens of controls.Now I'm planning another functionality where I have to move some of the controls and put others instead of them.I have to let the users to choose during runtime whether they prefer ver A or Ver B (means the other controls).
I have doubts what's the best practice to replace the controls.Should I hide the controls and replace them by others in runtime? (then the form may look messy during design time)Should I place them in a panel/group box and then replace the panels? (could be problem since I have some controls that should be displayed on both situations)
View 1 Replies
Jan 24, 2011
Lately I am having a problem accessing the controls of a form . I was used to use the following code back in VB6 :
Quote:
For Each GenericControl In Me.Controls
If TypeOf GenericControl Is System.Windows.Forms.Button And Mid(GenericControl.Name, 14,
[code]....
View 2 Replies
Feb 11, 2012
i have a winform and i have about 30 labels and 30 picture boxes on it. What i would like to do is fill each label and picturebox with a value and image from a backend database. I could have easily done this in vb6 using control struture , for eg.
for x = 1 to 30
picturebox(x).image = value from database
label(x).caption = value from database
[code]....
View 3 Replies
Dec 23, 2010
I have a form that sits on the user's desktop. It's only purpose is to display specific information about the computer. The layout is basically setup like this:
[Code]...
I want to be able to give the user the option to display whatever data they choose. In doing so, I'd like the form to resize itself based on the how many labels are in the form and for the labels to align vertically.
Can anyone point me in the right direction? For the form, I was thinking I could get the location of the last label and offset it's size by the location, or something similar.
View 2 Replies
May 1, 2012
if I set the property Opacity = 0, a form becomes transparent... but become transparent all it controls, too!how to make transparent ONLY the form and let the controls, labels, buttons etc. visible??
View 2 Replies
Jul 8, 2009
I have a problem. Controls is put inside form but don't appear when debug? I don't know what happened but. I put a Checkbox control and a button control named Button 3 on the my existing form. But when I debug the application. The Checkbox and Button 3 controls did not appear in the form? I try to put a message box which will be activate when Button 3 is clicked. I put a breakpoint there and I got this message. Breakpoint cannot be hit?
View 1 Replies
Sep 14, 2010
Is it possible to create instances of controls on a form ? Of course I mean visually , not just by code. After all, these languages define themselves as "Visual" so they should provide that possibility. It is important for the instances to be visible during design time because otherwise we could only guess where those controls might "land". Nevertheless , I have the feeling this is not possible in VB .NET but still I thought I should ask first ...
View 11 Replies
Jan 30, 2011
When I try to access the controls of a form which is not yet created (i.e. to modify the contents of a text box , to press a button etc) , I fail , usually without even an error message . I found out that the only way to make my program go right is to take care that the form is first created before I try to access anything on that form . However this means I must use the Show method to create it and then to Hide it , which leads to an instant awful optical effect . I remember back in VB6 there wasn't such a problem ; it seems that in VB6 each time I accessed a control on a not-created form led to the form being created silently . Is there any way I could do that in .NET too in order to access my precious controls ?
View 15 Replies