|
if you can give ip, username and password to the sql server then
why not directly connect to the database and insert or retireve records.
If i am getting your point right then if its a desktop application then direct connection won't do any harm to the database.
|
|
|
|
|
hi.. could you pls help me solve this problem..i am just finding the way "how to import .csv or .txt file into listview control??" i have a code which is akin to it but it reads everything inside the file add to the listview only one line.. so how about line by line adding??... below is my code..
Private Function ReadTextFile(ByVal sFileName As String) As String
Dim s As String
Try
Dim oFile As FileStream = New FileStream(sFileName, FileMode.Open, FileAccess.Read, FileShare.Read)
Dim oReader As StreamReader = New StreamReader(oFile)
s = oReader.ReadToEnd()
oReader.Close()
oFile.Close()
ReadTextFile = s
Catch
ReadTextFile = "Unable to open file."
End Try
End Function
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim s As String
s = ReadTextFile(Environment.CurrentDirectory & "\ReadMe.txt")
ListView1.Items.Add(s)
'MessageBox.Show(s)
End Sub
|
|
|
|
|
File.ReadAllLines returns an array of strings which is a valid data source for a list view.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Learn something new every day, this is why I lurk here, thanks.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Yeah thanks
I was always using a more complicated way of reading lines into an array
Lloyd J. Atkinson
"Logic will get you from A to B, but imagination will take you everywhere" - ALbert Einstein
I look at Microsoft, and turn to my poster on the wall saying: "Bang head here in case of stress".
|
|
|
|
|
Ok, well i am making a graphing calculator, and it's the simplest part i can't seem to figure out. I have a panel that is 416x416, which the graph will be drawn on. I have variables, xMin, xMax, yMin, yMax, that store the minimum and maximum for the x and y values. Now, the first step in rendering the graph is to draw the X and Y axises, and based on the minimum and maximum of the values will determine where the origin for the graph is. That's what i'm having problem with, i can't seem to generate code that will, in pixels, give the origin for the graph. Right now, the calculator only works if -xMin = xMax = -yMin = yMax, meaning the origin would be in the center of the 416x416 panel, at point (208, 208). If the xMax was twice as much as the -xMin, then the X axis would be 1/4 off of the panels left side. I can't seem to code an algorithm, when passed the xMax, xMin, ect., will return the origin of the graph. It will work with some values, but not all. Please let me know if i have not explained enough.
void Play() { try { throw Ball(); } catch (Glove) { } finally { Play(); } }
"Failure is only the opportunity to begin again, this time more wisely."
"Don't ask for a light load, but rather ask for a strong back."
|
|
|
|
|
have you tried (math.abs(xMin) + xMax) / 2
That is if xMin is "-200" and xMax is 400 the result is (200 + 400) / 2 = 300
EDIT: Unless you are already using negative values in X, Y then you would use
((math.abs(xMin) + xMax) / 2) - math.abs(xMin)
or
((200 + 400) / 2) - 200 = 100
|
|
|
|
|
A million thanks. I had tried something like that, but it was so complicated and didn't even work. Can't believe it was that simple.
void Play() { try { throw Ball(); } catch (Glove) { } finally { Play(); } }
"Failure is only the opportunity to begin again, this time more wisely."
"Don't ask for a light load, but rather ask for a strong back."
|
|
|
|
|
Hi everybody,
I built and app that uses threads for a number of task, and at the end of every routine I call the Abort() method for its respective thread. While looking at the thread count indicator at the Task Manager, I noticed that this indicator always increases while the Output window indicates that the threads had successfully exited.
Is this normal or am I doing something very wrong?
Thanks great minds for your guidance.
Alex.
|
|
|
|
|
alexvw wrote: I call the Abort() method for its respective thread
As MSDN says about Thread.Abort(), The thread is not guaranteed to abort immediately, or at all. It's always good to exit the threads rather than calling Abort() . Please post your code so that we can come up with better suggestions.
|
|
|
|
|
//Declare thread var
Private Shared BkGrthread As Threading.Thread
//call sub that starts the thread
Private Sub Frm_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
...
InitThread(BkGrthread, 1)
...
End Sub
//Sub that starts the thread
Private Sub InitThread(ByRef Thread As Threading.Thread, ByRef ThreadIndex As Byte)
Try
Select Case ThreadIndex
Case 0 : Thread = New System.Threading.Thread(AddressOf ReceiveWkStat)
Case 1 : Thread = New System.Threading.Thread(AddressOf ReceiveTCPMsg)
Case 2 : Thread = New System.Threading.Thread(AddressOf ReceiveSys)
End Select
Thread.IsBackground = True
Thread.Priority = System.Threading.ThreadPriority.Normal
Thread.Start()
Catch
Msg(Err.Description, 16, "FrmMain::InitThread")
End Try
End Sub
//the following code was not created by me, I copied and modified it to fit my needs (so far it seems to work!)
Private Sub ReceiveTCPMsg()
Dim _data(1024) As Byte
Dim iMsg(), _Message As String
Dim TCPIP As Net.Sockets.TcpClient
Dim Stream As Net.Sockets.NetworkStream
Try
TCPIP = UDPManager.AcceptTcpClient
Stream = TCPIP.GetStream : Stream.Read(_data, 0, 1024)
TCPIP.GetStream.Close()
Stream = Nothing : TCPIP = Nothing
_Message = System.Text.Encoding.ASCII.GetString(_data)
iMsg = _Message.Split(",")
Select Case iMsg(1)
Case 1 : Invoke(sLoadNewEvent, New Object() {iMsg}) '**New Event Insertion
Case 2 : Invoke(sRemoveEvent, New Object() {iMsg}) '**Event Deletion
Case 3 : Invoke(sItemUpdate, New Object() {iMsg}) '**Event Item Update
Case 5 : Invoke(sTimeChange, New Object() {iMsg}) '**Update Event's Time
Case 6 : Invoke(sStatusChange, New Object() {iMsg}) '**Update Event's Status
Case 7 : Invoke(sTypeChange, New Object() {iMsg}) '**Update Event's Type
Case 11 : Invoke(sNewEventData, New Object() {iMsg}) '**Event Data
Case 12 : Invoke(sDeleteData, New Object() {iMsg}) '**Del Event Data
Case 13 : Invoke(sMaintenance, New Object() {iMsg}) '**system Maintenance
Case 15 : Load_IncrementValues()
Case 99 : UnconditionalEnd()
End Select
Catch
Msg(Err.Description & Chr(10) & _Message & Chr(10) & Err.GetException.StackTrace, 16, "MainMod::ReceiveTCPMsg")
Finally
InitThread(BkGrthread, 1)
End Try
BkGrthread.CurrentThread.Abort()
End Sub
This is all the code involved. I am using VS2002 Fmwrk 1.1. Most subs modify several controls on the main thread, therefore the use of Invoke.
Please, feel free to laugh or cry upon this code
Thanks for your time.
<div class="ForumMod">modified on Saturday, August 16, 2008 7:20 AM</div>
|
|
|
|
|
|
What you talking about Willis ?
I am guessing Excel somehow, but you don't make it remotely clear.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Hi
I have two locations referenced by
point1 = A5
point2 = A10
I need to use these variables in a calculation ie
=sum(point1:point2)
however this doesn't work?
when I use this statement
ActiveCell.Offset(0, 3).Value = "=sum(point1:point2)
any work around / solution?
if you require additional info let me know?
|
|
|
|
|
Please don't ask twice. Please try to use intelligent headers. EVeryone here wants help. Please make it clear what you're asking about. Visual Basic.NET does not have any control which references locations by A5 and A10, or has an ActiveCell, It seems likely you're talking about Excel, but VBScript or interop ? How are we to tell ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Matthew Leggett wrote: I have two locations referenced by
point1 = A5
point2 = A10
I need to use these variables in a calculation ie
=sum(point1:point2)
however this doesn't work?
when I use this statement
ActiveCell.Offset(0, 3).Value = "=sum(point1:point2)
any work around / solution?
if you require additional info let me know?
Try this:
ActiveCell.Offset(0, 3).Value = "=sum(" & Point1 & ":" & Point2 & ")"
This is of course assuming that you have Point1 and Point2 declared as strings.
|
|
|
|
|
Does anyone know how to shutoff/disable the automatic "feature" of changing the time of a date field when changing time zones? I want my dates to be left alone. I know I can change the field to type string but extra conversions would be necessary to compensate for changing the type. (this auto-feature happens when I am using a webservice)
Thanks,
Nathan
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
You cannot remove the time component of the datetime type. You can however display any part of that component using format. You can also refuse to store the time value when writing it to the database (I do this everywhere EXCEPT where I explicitly need to time component) by using TODAY instead of NOW.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
hi, i am still a novice vb programmer.i want to know one thing.i want to write some code so that it will control objects outside my form.i mean generally we write code to work with the objects(say command button,list box etc.) that we place on our form.but how can i manipulate and take control of the objects outside my form.say,i want to write code so that a message box will be shown if a user double clicks on drive C: in my computer window.i think i need to take help of API.but i can't understand how to do it.anyone can help me out there? i am just freaking out.plz help me.
romance
romance
|
|
|
|
|
romance - see the one votes, they signify a stupid question, you have an inflated idea what you can do as a programmer specifically as a VB programmer. I imagine a very good developer (probably C++) with a deep knowledge of win32 api may be able to manage this but a newbie, not a chance.
Try something simple first, create an application that executes some business logic, retrieves and stores data, you know simple stuff. After you have spent a number of years gaining a well rounded knowledge of the programming tools available to you, think of this question and laugh at yourself.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
i didn't mean to offend someone.yet you offended me.i think you don't know the answer of my question, nor do you have any knowledge of programming.
thanks and please don't disturb anyone by answering stupidly
romance
|
|
|
|
|
It's not that I don't know the answer to your question it's that your question does not make sense. It also indicates that you have no knowledge of the use and limitations of VB.
My response may have upset you but you will remember it, therefore I consider it a job well done. Get some understanding of the tools you propose to use, think about the projects you want to do, start working on the projects and when you run into a problem with coding, come back and we will help.
Note that no one responded to your question except to indicate it deserves a 1 vote.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
hi,
here i want to know, can i make a new variable, "Dim Variable as type" at the run time
when the my application load up it will create a new variable that can store a data.. is that possible? how can i make it?
|
|
|
|
|
shee_dee86 wrote: here i want to know, can i make a new variable, "Dim Variable as type" at the run time
when the my application load up it will create a new variable that can store a data.. is that possible? how can i make it?
Your question is not clear. Please try to explain what you wanna do.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
shee_dee86 wrote: "Dim Variable as type" at the run time
when the my application load up it will create a new variable that can store a data.. is that possible?
That is what it does
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|