Here is what I want it to do:
1: My form uses my class library dll to use a command called moveobject
2: My form sends button1 to the byval
3: The button on the form is moving
Here is what it does right now:
1: My form uses my class library dll to use a command called moveobject
2: My form sends button1 to the byval
3: Returning an error
I want to use the objects in the designer in the class library like this (GM is the name of my class library):
This is the form: - Dim GMF As GM.functions
-
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
-
GMF.Move_fixed(Me.Button1, "1", 10)
-
End Sub
This is the class library: - Public Class functions
-
Dim way2
-
Dim obh As Object
-
Dim sp
-
Public Function Move_fixed(ByVal objectname As Object, ByVal way As String, ByVal speed As String)
-
way2 = way
-
obh = objectname
-
timer(speed)
-
End Function
-
Dim tt
-
Public Function timer(ByVal time As String) _
-
As String
-
tt = 100
-
sp = time
-
InitializeComponent()
-
End Function
-
Private Sub InitializeComponent()
-
Me.Timer1 = New System.Windows.Forms.Timer
-
'Timer1
-
'
-
Me.Timer1.Interval = tt
-
'
-
'Form1
-
Timer1.Enabled = True
-
End Sub
-
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
-
If way2 = "1" Then
-
With obh
-
.Left = .Left + sp
-
.top = .top + sp
-
End With
-
End If
-
If way2 = "2" Then
-
With obh
-
.top = .top + sp
-
End With
-
End If
-
If way2 = "3" Then
-
With obh
-
.Left = .Left - sp
-
.top = .top + sp
-
End With
-
End If
-
If way2 = "4" Then
-
With obh
-
.Left = .Left + sp
-
End With
-
End If
-
If way2 = "5" Then
-
Timer1.Enabled = False
-
Timer1.Stop()
-
End If
-
If way2 = "6" Then
-
With obh
-
.Left = .Left - sp
-
End With
-
End If
-
If way2 = "7" Then
-
With obh
-
.Left = .Left - sp
-
.top = .top - sp
-
End With
-
End If
-
If way2 = "8" Then
-
With obh
-
.top = .top - sp
-
End With
-
End If
-
If way2 = "9" Then
-
With obh
-
.Left = .Left + sp
-
.top = .top - sp
-
End With
-
End If
-
Timer1.Enabled = True
-
End Sub
-
Friend WithEvents Timer1 As System.Windows.Forms.Timer
-
End Class
7 1146 QVeen72 1,445
Recognized Expert Top Contributor
Hi,
You are wanting to Pass the Form Control to class module, in that case you should not pass with "ByVal".
Remove ByVal for the Object and check..
REgards
Veena
Its still not work because when I remove byval it returns.
I have VB.NET
Try passing the form by reference (ByRef)
Try passing the form by reference (ByRef)
Yes, I think they changed things. In VB6, ByRef was the default, so you only ever had to specify when you wanted to pass by value. In later versions, I believe ByVal is now the default, so if you want to pass a reference you need to say so.
Its still not work because when I remove byval it returns.
Huh?! It returns what?
On a slightly more positive note, I would recommend changing that big long stream of If way2 = tests. A Select Case would be the ideal, or you could just convert all but the first into ElseIf statements. Either way, it would make the code much easier to maintain.
At present, to be certain of what will happen at any point, you have to read carefully through all the prior ones, to ensure that the value of way2 can't change. Either of the two suggested alternatives would make the options all mutually exclusive, removing this requirement. This would have the added advantage of executing (very slightly) faster, since it would stop checking the rest of the conditions once it hit the True one.
Hi the code is working 100% when I copy it directly inside the code in the form application, but it dont work in a class library that is the problem and yes Byval is now the default.
This is what I want it to do:
form with a button>uses class library>button is moving
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: C-Sharper or C-Hasher, one of the two |
last post by:
Hi,
I have a C# class libary (Class1) which is inherited by another class in a
Windows Forms app. I want this other class to implement some, but not all of
the features of the base class. How can I completely hide (within the IDE)
the members of the base class library i.e. only expose those members that I
want exposed? I've tried some methods gleaned by googling for "hiding base
class members" which suggested using things like "new" and...
|
by: Roger Gordon |
last post by:
I have the VB.NET Standard Edition. I'm taking a VB.NET class in school.
Last night we tried to create a class libary and there was no option to do
this in the Standard Edition. Our instructor has Visual Studio.NET and so
he does have the option to create a class libary.
Does anyone know if there is a way to create a class libary in VB.NET
Standard Edition, or do I need to go out and buy Visual Studio.NET?
|
by: Ron |
last post by:
Hello,
I need to create/instantiate a global class library
project so that 2 EXE's can write to the same class
library form in the same instance of the class libary. I
am thinking something along the lines of declaring the
class library project in a global assembly and then
referencing this global declaration from each of the 2
EXE's. Is the global assembly where I could declare my
global class libary project? How to do that?
|
by: Tom Edelbrok |
last post by:
I am creating a class libary of VB.Net utilities that will be built into a
DLL. This DLL can be used by our development VB.NET programs when they want
to call standard in-house utilities.
I create the class libary MYCLASSLIBRARY.VB by inserting a whole bunch of
classes, ie:
public class class1
end class
public class class2
|
by: David McCallum |
last post by:
First excuse my ignorance, but I'm completely new to VS2005 development
I've created a new project and want to add an already written class stored
elsewhere on the computer to the project.
This class will be used by a number of projects.
The problem is, if I right-click on the Project File in the Solution
Explorer and add the class a copy of the class is placed in the projects
folder. Any changes to the original class do seem to be...
| |
by: Rich |
last post by:
I put together a simple test class libary (VB2005) with one class and one
function that takes an integer argument and adds 10 the argument and returns
that number. Then I created a simple VB2005 app to test my class library
function. I made a reference to testClassLib.dll in the new project. Then I
made a function calls in a button sub and wrote the results to the console.
This worked fine.
Now I am trying to add a reference to a...
|
by: Peter Bradley |
last post by:
OK. A bit behind the times, I know; but we're just moving over to .NET 2.0.
How on earth do you manage configuration settings in a class library in .NET
2.0? In version 1.1, we used a handy class called AssemblySettings that
someone (I forget his name) had written. When the class library was
finished, you deployed it to the GAC and put the configuration files in the
GAC with the class library assembly. This no longer works. In fact...
|
by: Jacob |
last post by:
Hi!
Where do i find .NET class libary in Visual studio? I mean if you would like
to browse through the classes and members. Or if you want to search fr specific
classes or members.
Thanks in advance.
Jacob
|
by: vedrandekovic |
last post by:
Hello,
Does anybody have any idea how can I embed my modules to libary.zip
and use it from my application.For example if user write this code in
my TextEntry ( or something like that, textentry is created with
wxpython ) :
import d3dx # directpython module
frame=d3dx.Frame(u"My frame") # create frame
frame.Mainloop() # run it
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |