|
Your code, as far as I can see, does nothing other than open a datareader and close the connection. What are you trying to do? (please don't say "update my database", it's the most useless answer you can give)
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hello every one,
I have a public function in a existing application which is called from many different forms. The form name is also passed but as a string to his function.
What i wanted to do is close the form from which it is called depending on certain conditions
how i can do that
button_click
{
call test("frm1")
}
Public function test(byval formName as string)
{
'condition
'close the form which called this function
'I want to some how execure frm1.close()
}
|
|
|
|
|
First you need to store the collection of open forms so that you can find them again, a List or Collection. A manager class to handle adding and removing/closing would be preferred to handle the List/Collection.
In the function, look for the form with the name, and ask the manager class to close the form.
If a form is closed via UI, inform the manager class to remove itself from the List/Collection.
You will need to handle situation where multiple form of the same type has been opened.
|
|
|
|
|
I need help urgently for this question. Can someone help me on it.
|
|
|
|
|
Since you want to do this in VB.NET instead of C# I assume you already have the code in C#. Simply translate it to VB.NET (Search for a converting tool C# -> VB.NET on google).
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
pls i have a project that i want to read a file from C:\WINDOWS\system32\Logfiles\MSFTPSVCg but it show error that another process is reading the file. this app uses ftp. i suggest the problem is the ftp reading the file. how can i overcome this and read the file
|
|
|
|
|
you should be able to share the file without problems
try something like:
dim fs as new system.io.filestream("yourfilenamehere", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
The part at the end of your filestream method (FileShare.ReadWrite) tells your filestream that it can share the file with other proccesses.
|
|
|
|
|
can i use sometime like
s = file.readalllines(path) after your statement to read all the line. if no how can i read all line thank
|
|
|
|
|
Hmm.. i suggest you do a little looking up on google before you continue cause looking at your pseudo code.. you are not really catching on... Depending on what you want.. you could do the following to read the entire file:
dim sMyVariableThatWillContainTheWholeEntireTextOfTheFile as string
dim fs as new system.io.filestream("yourfilenamehere", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
dim sReader as new streamreader(fs)
sMyVariableThatWillContainTheWholeEntireTextOfTheFile = sReader.ReadToEnd
However.. take under consideration that depending on the size of the file, this might not be the best way to go.. you could also do :
sReader.ReadLine()
to read the file line by line and perform actions on the content of that line..
Take a look at the streamreader class here: http://msdn.microsoft.com/en-us/library/system.io.streamreader.aspx[^]
|
|
|
|
|
if u have permission to access the file,
just copy it to a specific place then read the copy !
" I love deadlines. I like the whooshing sound they make as they fly by. "
|
|
|
|
|
I'm new to VB.NET, currently I'm learning programming here. I have a Window Form(e.g. FrmLogin.vb) and a module which used to run the program (e.g. Module1.vb).
I have declared a few public string variable as follow:
Option Explicit On
Imports System.Data
Imports System.Data.Odbc
Imports System.Configuration
Module Module1
'User detail variable
Public UserID As String
Public UserName As String
Public UserPassword As String
End Module
And I used the FrmLogin to verify the user by connecting to MySQL database. After the user successful login,I will set the UserID,UserName and UserPassword data load from the database which need to be used in my program for the future identification. But when I open another new form I found that these public variable is no value. Can anyone tell me how should I share a public variable inside VB.NET? This data will be used by alot of Form inside this application.
Thank you for reading.
Regards
Drexler
|
|
|
|
|
Sorry, we cannot see your question. Please reformat your post so all the text is visible.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Sorry Ashfield,
What I need is declaring a variable for global used in my Vb.NET Window Form Application. I am trying to declare the global variable inside a Module1.vb. I have a few forms that using this global varaiable and it doesn't really works. Anyone could tell me how to declare a global variable which can share the variable used in all other different forms or class?
Regards
Drex
|
|
|
|
|
From version 7 (VB.NET 2003) VB is an object oriented language, which means that there are no longer any global variables. All variables are either members of a class or local in a method.
To set up variables that you can use like you did use global variables, you can use static variables. You use the Shared keyword to do this, and those variables are members of a class rather than members of an instance of the class.
Public Class UserDetails
Public Shared UserId As String
Public Shared UserName As String
Public Shared UserPassword As String
End Class
You can access the variables from anywhere by specifying the class name and the variable name:
UserDetails.UserId = "42"
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hello Guffa,
Do you mean that I should create all the public share variable into one main module,so all the form can use all the data inside this main module? And how can I insert or retrieve the data of UserID when I need it in other form from this class?
Hope to get some solution about this from you all.
Thank you~!
|
|
|
|
|
Modules is something that for some reason survived from VB6. A module is compiled into a class where all the members are static, so if you declare variables in a module, you should be able to access them from anywhere.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Yeah,thanks Guffa. Can you give me some idea how should I declare the variable of my Window Form Application? Let me further explain my situation below:
Option Explicit On
Imports System.Data
Imports System.Data.Odbc
Imports System.Configuration
Module Module1
'User detail variable
Public UserID As String
Public UserName As String
Public UserPassword As String
End Module
This is how I test my retrieve data using Form from the varaiable in Module1.vb:
Messagebox.show(UserID)
Messagebox.show(UserName)
Messagebox.show(UserPassword)
But all the messagebox prompup is Nothing. So,anyone can tell me how should I declare my variable so I can used anywhere in my project? The UserID,Username and Password is used for verification when working with certain function or task.
Thank you for reading.
Regards
Drexler
|
|
|
|
|
It looks like you have declared your variables correctly, the reason the messagebox is showing nothing is becasue you haven't assigned them a value.
Try
UserID = "12345"
Messagebox.Show(UserID)
|
|
|
|
|
Yeah,thanks Liqs. I have solve it by converting the data to string instead of boolean when I assign into the variable. This solve my problem,thank you my friend.
Regards
Drex
|
|
|
|
|
Yeah,thanks Guffa. I have solve it by converting the data to string instead of boolean when I assign into the variable. This solve my problem,thank you my friend.
Regards
Drex
|
|
|
|
|
So the problem was not at all in the code that you posted, but in some other code that you didn't post...
Assigning a boolean value to a string variable is such an obvious error. I wonder why I didn't see that by looking at the code that you posted?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
i cant debug my usercontrol i have applied in another solution
settings problem maybe? because i was able to debug before.
if grid.reccount = 0 then
before it would go into the function reccount but now
it just doesnt
please help
tnx in advance
|
|
|
|
|
Either Clean the solution and rebuild or check configuration Manager setting in Build Menu.
hope this helps
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
done cleaning usercontrol solution and the new application soultion
it still doesnt debug they way it was before.
this works
if myfunction() then
but this doesnt
if usercontrol.reccount = 0 then
already set debug build in configuration manager of new application
but still no success
|
|
|
|
|
sources is 8051 MCU
07 01 11 12 13 17 255 128 45 128 0A 01
07 01 as start flag
0A 01 as end flag
11 12 13 17 255 128 45 128 as data
data range is 0-255
8051 sources incessancy
exp
07 01 11 12 13 17 255 120 45 128 0A 01
07 01 12 188 13 17 201 121 46 129 0A 01
07 01 13 111 13 17 200 122 47 130 0A 01
07 01 14 121 13 17 255 123 48 131 0A 01
07 01 16 132 13 17 255 124 49 132 0A 01
.........................................
TEXT2(127)
how to sort in textbox and real refresh correct textbox array place
exp
text2(0)=11
text2(1)=12
.
.
text2(7)=128
text2(8)=12
.
.
---------------mycode----
but not sort in correct place
Private Sub MSComm1_OnComm()
Select Case MSComm1.CommEvent
Case comEvCD
Case comEvCTS
Case comEvDSR
Case comEvRing
Case comEvReceive
Dim b() As Byte
b = MSComm1.Input
Do Until b(lo) = 7
Loop
For ko = 0 To 127
lo = lo + 1
lo = lo Mod 128
Text2(ko).Text = Val(b(lo) * 4 * 0.00488) ??????
Next ko
Case comEvSend
End Select
End Sub
|
|
|
|