|
Yes it was a typo. A messaage comes up saying:
"Reference to a non-shared member requires an object reference"
The modifier of the text box in form1 is Friend.
ARGG!! Why VB.NET is so crapy???!!?!
if i type form1.lblTest.text = "Test" then there is a blue wiggly line under it.
Trying to find the way
|
|
|
|
|
what's the name of your form1? is it really form1?
Unlike vb6, VB.Net does not automatically create a variable for a form, you have to manually create it.
Try setting the text without referencing the form.
lblTest.text = "Test"
See if that works
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
|
|
|
|
|
No still doesn't work.... yes i keep my forms form1, form2 etc for now. I am new in VB.NET.
Thanks for all the help though.
Trying to find the way
|
|
|
|
|
Hmmm, that's strange.
Are you sure that there's a line:
Friend WithEvents lblTest as Label
in your form1?
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
|
|
|
|
|
I found a article with the follwing code:
Public Class Form1
Inherits System.Windows.Forms.Form
Dim F2 As New Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowButton.Click
F2.ShowDialog(Me) ' Show Form2
Me.UserLabel.Text = "Current User : " & Form2.NuNameTB.Text
End Sub
======================================================================
Public Class Form2
Inherits System.Windows.Forms.Form
Public Shared NuNameTB As TextBox
Private Sub CloseButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseButton.Click
' Assign this form's TextBox to the Object Variable
NuNameTB = UsersName
' Now close the form
Me.Close()
End Sub
================================================================
it seems to be working ok. Thank you for all the support Nick and Colin. VB.NET is a bit annoying sometimes. Now if i could get help about the paper size collection.
Thanks again.
Trying to find the way
|
|
|
|
|
Actually, it's not a problem with VB.NET. You would have the exact same problem with C# too.
This is beause your not following proper OOP coding practices to get what you want done.
Try reading Working with Multiple Forms in Visual Basic .NET: Upgrading to .NET[^] on MSDN for a better explanation of moving data between forms.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have a problem with enumerating a list box with the available papers sizes of a printer. I want to be able when i click on the printer combobox the listbox to be able to fill with the available paper sizes. So far it seems that it's able to find only the default paper sizes.
I have post this question again earlier on but it was lost in all the new entries. I am really lost of what to do . Any help will be much appriciated. Thank you in advance...
Here is the code so far. cmbPrinter = combobox of available printers.
lstPaper = listbox of available paper sizes.
============================================================================
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim objPrint As New System.Drawing.Printing.PrinterSettings
Dim strItem As String
Dim strPrinters As String
For Each strItem In objPrint.InstalledPrinters
cmbPrinter.Items.Add(strPrinters & strItem)
Next
End Sub
Private Sub cmbPrinter_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbPrinter.SelectedIndexChanged
' Add list of supported paper sizes found on the printer.
Dim searchstring As String
Dim SearchChar As String
Dim MyPos As Integer
Dim i As Integer
Dim pkSize As System.Drawing.Printing.PaperSize = Nothing
SearchChar = "A4"
For Each pkSize In printDoc.PrinterSettings.PaperSizes
lstPaper.Items.Add(pkSize.PaperName)
Next
For i = 0 To lstPaper.Items.Count - 1
lstPaper.SelectedIndex = i
searchstring = lstPaper.SelectedItem()
MyPos = InStr(searchstring, SearchChar)
If MyPos = 0 Then
lstPaper.Items.Remove(0)
Else
paperToUse = searchstring
End If
Next
updateDisplay()
End Sub
I can fill the combobox of the printers and the list box of the papers. BUT when i click on another printer the program DOSEN'T give me the list of the paper sizes on the new selected printer. It's like it stucks in the paper sizes of the default printer...
HEEEEEEEEEEEEEEEEEEEEEEEEEELP!!!
Trying to find the way
|
|
|
|
|
Hi all,
I want to build an application that can get emails from my yahoo, hotmail and gmail accounts and display them formatted in a text box. Please guide me where to start for this project i can do the second part but have no idea how to start working on the first part as how the application will login at hotmail or yahoo and how'll it get the emails.
Thanks in advance.
Regards,
Umar Inam
UI
|
|
|
|
|
Do hotmail and yahoo expose their mail functionality to this sort of program ? I'd guess the best place to find out is hotmail and yahoo.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I am not sure that they do. but there should be work arround as we can check the mails through browser. now just it has to communicate with my app or something like that any one please??
Regards,
Umar Inam
UI
|
|
|
|
|
If they don't expose that functionality, then you need to control IE and get it to click on each new email, grab the text from it, and copy to your app. Sounds like a lot of work for little reward to me, and as soon as they change the pages, your app won't work anymore.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Yep thats wat i thought and thats why i am lookking for a work arround.
UI
|
|
|
|
|
I am working on a project where the DataLayer and Business Objects will be written in C# and the UI will be VB.Net and or ASP.Net.
For testing I have created simple c# class and collection class.
Both objects are under the same namespace
I compiled them using the build option in the IDE.
In VB.Net I have referenced the c# dll and used imports.
The intellisense work and I am able to see the namespace and my objects.
When I use the following code:
Dim oWidgets As New Widgets ' the collection
oWidgets can not be used (intellisense does not work)
and there is syntax error line under it. When I hover over it i get 'declaration expected'
HC
|
|
|
|
|
hagridcracker wrote:
and the UI will be VB.Net and or ASP.Net.
Why would you do such a thing ?
ASP.NET requires you use VB.NET or C#, it's not a different thing altogether.
hagridcracker wrote:
oWidgets can not be used (intellisense does not work)
Does it compile/run ? Maybe intellisense is all that is broken.
hagridcracker wrote:
and there is syntax error line under it. When I hover over it i get 'declaration expected'
Does Widgets have a public default constructor ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Why do such a thing...
I've jsut started coding in both VB.Net and C#.. just nver used one with the other yet. I've been coding in vb 3-6 since 93' so I am very familiar with OOP..
Short Rant:
Also if you are lucky enough to get a gig with Microsoft or a contract they usually (as in 99.9% of the time) require all coding to be in c# whether it is a stand alone app/part of a solution or if you are doing asp.net coding...
there are more short term vb.net gigs than c# and c# pays better, but doing the ui in vb is much easier faster.
-- Nope it will not compile
-- if you mean the Wiget() method of the Widget Class yes.
JG
|
|
|
|
|
hagridcracker wrote:
I've been coding in vb 3-6 since 93' so I am very familiar with OOP..
Would I invoke a holy war if I said I had no idea that VB had any OOP support before VB.NET ? I didn't even think it had classes until recently ?
hagridcracker wrote:
Also if you are lucky enough to get a gig with Microsoft or a contract they usually (as in 99.9% of the time) require all coding to be in c# whether it is a stand alone app/part of a solution or if you are doing asp.net coding...
So why not do it all in C# ?
hagridcracker wrote:
there are more short term vb.net gigs than c#
Ah.... Yeah, I had to fight not to do my last contract in VB.NET. I just flat out refused, and they took me anyhow.
hagridcracker wrote:
c# pays better
There's some justice in the world then....
hagridcracker wrote:
doing the ui in vb is much easier faster.
Why ? I seriously find that incredibly hard to believe.
hagridcracker wrote:
if you mean the Wiget() method of the Widget Class yes.
Yes, that is the default constructor. Then I have no idea why you'd have that problem, sorry.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I got into objects seriously around ver 6 i believe they have been around since ver 5.
the ui... there are a few gotchas that will get you coming from vb6/vb.net. nothing major but a bit confusing when you start out other than that the coding now is so similar, but just different enough for not so serious developers to think that its hard.
The bulk of my code is in the datalayer and business objects anyway at this will be in c#.
I leave my customers with dlls they can just reference and use.
|
|
|
|
|
Hi
You were not specifying that where the Widgets class written. However I guessed it has been in C# class library. I am sure that it was the problems of namespace.You please verifiy the code file that contains ‘Widgets’ class definition for namespace declaration.
M.Sendilkumar
TVS Infotech Ltd
Chennai
|
|
|
|
|
Both classes are located in the same name space and all are visible using the object browser.
|
|
|
|
|
I made a newbie mistake and was wotking in the wrong scope. After moving my code around it works as expected.
JG
|
|
|
|
|
Hi
Can someone help me out with the comboboxes?
I'm trying to make the items that I add thru my program stay in the combobox and I don't know the right code.
Gap
|
|
|
|
|
What kind of item that you want add. Usually the item in the combobox just present during the time that you run your application (store in memory). If you want to store an item everytime your program load you need to write it in the formload event. If you want it to be more flexibility, you could store the information of the item that you want to add in the text file or database. So when you load your application you can load that item from text file or database in your combobox as normally.
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
gosh thanks
i'm trying to add text by the way
and how do I program that...?
|
|
|
|
|
Try to find the information from here[^]. It contain some sample application that demonstrate to load the database in the combobox. If you still have the problem, let me know.
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
ok Thanks so much
|
|
|
|