|
Hi .
I've managed to create a printing method and at the moment i'm using hardcoded margins. i need advice on things i've noticed which
1. print preview is aligned where as print out is only slightly off.
can u give me advice on what to code for e.g. do i need to simply add pagesettings dialog to manipulate margins or should i get real printer hardware margins and use them. what is the pro way to do this and the best way.
perhaps you can also be kind enough to show me a source example aswell.
Robbo
|
|
|
|
|
I have created a class in my project in a seperate file to the main form. When I try to use the maths class functions in this class such as Math.Abs(x) I get a build error message " Name 'Math' is not declared" but when I use the same function in the main form I have no problem with using it. Can anyone help?
|
|
|
|
|
use System.Math.Abs(x)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
I am trying to make a note card program, can someone help me out? I need help making the program, i would like it to have a form with a textbox for a word, definition, sentence, and a synonym. And users should be able to add words and save lists from the initial form. Then when they click a study button, another form should open up, and it should randomly select a word from the list and show them only the word. Next, when they click Flip! they should see the definition, sentence, and synonym. I will post what i have so far, but my vb skills are a bit rusty, so if someone could help me, it would be appreciated. http://www.mediafire.com/?enkqyoyzwzy
|
|
|
|
|
IMHO, What do you really need is a good VB tutorial.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Alright, update, can someone tell me why this doesn't work, (don't worry, the layout will change, i have it like this for testing). I suspect that the problem is in the part where it saves the cards.
Public Class Form1<br />
Dim mode As Integer<br />
Dim words(30) As String<br />
Dim definitions(30) As String<br />
Dim synonyms(30) As String<br />
Dim sentences(30) As String<br />
Dim rotation As Integer<br />
Dim temp As String<br />
Dim Wordnumber As Integer<br />
<br />
Private Sub CreateCard_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreateCard.Click<br />
mode = 1<br />
Wordnumber = 1<br />
Label1.Text = "Card Created"<br />
temp = Word.Text<br />
words(Wordnumber) = temp<br />
temp = Def.Text<br />
definitions(Wordnumber) = temp<br />
temp = Sentence.Text<br />
sentences(Wordnumber) = temp<br />
temp = Syn.Text<br />
synonyms(Wordnumber) = temp<br />
Wordnumber = Wordnumber + 1<br />
End Sub
or in the part where it recycles the words when it reaches a blank one
<br />
Private Sub flipcard_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Flipcard.Click<br />
synstudymode.Text = synonyms(rotation)<br />
sentencestudymode.Text = sentences(rotation)<br />
defstudymode.Text = sentences(rotation)<br />
wordstudymode.Text = words(rotation)<br />
If words(rotation) = "" Then<br />
wordstudymode.Text = "You have completed one rotation."<br />
rotation = 1<br />
End If<br />
rotation = rotation + 1<br />
End Sub<br />
I have posted the entire source at:
http://www.mediafire.com/?9n42k3mj3rz
-- modified at 19:59 Thursday 4th January, 2007
|
|
|
|
|
Hello All,
I have a project I am currently working on using VB .NET and VS 2005. Basically one of my classes maintains a collection of various objects all derived from a base class, but different. I want each of these derived classes to have a common method, but the paramaters for the method will vary.
Example, here is a cut down version of the base class and derived classes and what I want them to do.
Class clsString
public mustoveride sub AddPoint(index as integer, pnt as clsPnt)
End class
Here are some versions of the derived classes.
Class clsString3D
inherits clsString
public overrides sub AddPoint(index as integer, pnt as cls3d)
'do some other stuff here
End class
Class clsString6D
inherits clsString
public overrides sub AddPoint(index as integer, pnt as cls6d)
'do some other stuff here
End class
My program returns the object in this manner
Public function getString(byref name as string) as clsstring
getstring=string.item(name)
end function
I then call the function like this
Dim STR as clsstring
dim P6 as new cls6D
p6.setvals(5,7,34.6,45,3)
str=MDL.getString("MC01") 'this would in a working version return a string of clString6D
Str.AddPoint(4, P6)
Now I realise that you cannot override the function if the function signature is not the same, but shadowing doesn't seem to work either. Could someone please explain to me correct way for me to code what I want to do, or even if it is possible.
Regards,
Martin Duke
|
|
|
|
|
Aren't you able to deal polimorphically with pnt also?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hello,
Yes, you're right, because all the point classes derive from a base class, clsPnt, I can, that solves my problem, thank you for your help.
Kindest regards,
Martin.
|
|
|
|
|
I need to format the date when the values are inserted to the MySQl db. All other columns work fine but all of the date columns are inserted as zeroes and in a different format, for example 0000-00-00. Any ideas?
Code:
Dim myConnString As String = "DRIVER={MySQL ODBC 3.51 Driver};" & _
"SERVER=192.168.1.27;" & _
"DATABASE=testship;" & _
"USER=;" & _
"PASSWORD=;" & _
"OPTION=3;"
Dim MyConnection As New Odbc.OdbcConnection(myConnString)
MyConnection.Open()
Dim MyCommand As New Odbc.OdbcCommand
MyCommand.Connection = MyConnection
MyCommand.CommandText = "INSERT INTO ls_orderitems (OrderDate, OrderCustomer, OrderAcctNum, OrderType, OrderSoNum, OrderItemPartNum, OrderItemPartDesc, OrderItemQty, OrderItemQtyRec, OrderItemQtyDtRec, OrderItemBO, OrderItemBODt,OrderItemCanceled, OrderItemCanceledDt, OrderItemNotes, OrderItemPONum, OrderItemRetailPrice, OrderItemSalePrice, Status, InsertDate) VALUES ('" & OrderDate & "','" & OrderCustomer & "','" & OrderAcctNum & "','" & OrderType & "','" & OrderSoNum & "','" & OrderItemPartNum & "','" & OrderItemPartDesc & "','" & OrderItemQty & "','" & OrderItemQtyRec & "','" & OrderItemQtyDtRec & "','" & OrderItemBO & "','" & OrderItemBODt & "','" & OrderItemCanceled & "','" & OrderItemCanceledDt & "','" & OrderItemNotes & "','" & OrderItemPONum & "','" & OrderItemRetailPrice & "','" & OrderItemSalePrice & "','" & Status & "','" & InsertDate & "'" & ")" '& "','" & 'TimeStamp & "'" & ")"
MyCommand.ExecuteNonQuery()
MyConnection.Close()
|
|
|
|
|
Change this to a parameterized query. The parameter objects take care of the translation for you. You can read why they are a good thing here[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Do you have any similar samples because I am not familiar with parameterized queries?
|
|
|
|
|
Here is some code that I tried but the dates are still being displayed as 0000-00-00 in db:
Dim myConnString As String = "DRIVER={MySQL ODBC 3.51 Driver};" & _
"SERVER=192.168.1.27;" & _
"DATABASE=testship;" & _
"USER=;" & _
"PASSWORD=;" & _
"OPTION=3;"
Dim MyConnection As New Odbc.OdbcConnection(myConnString)
MyConnection.Open()
Dim MyCommand As New Odbc.OdbcCommand
MyCommand.Connection = MyConnection
MyCommand.CommandText = "INSERT INTO ls_orderitems (OrderDate, OrderCustomer, OrderAcctNum, OrderType, OrderSoNum, OrderItemPartNum, OrderItemPartDesc, OrderItemQty, OrderItemQtyRec, OrderItemQtyDtRec, OrderItemBO, OrderItemBODt,OrderItemCanceled, OrderItemCanceledDt, OrderItemNotes, OrderItemPONum, OrderItemRetailPrice, OrderItemSalePrice, Status, InsertDate) VALUES ('" & OrderDate & "','" & OrderCustomer & "','" & OrderAcctNum & "','" & OrderType & "','" & OrderSoNum & "','" & OrderItemPartNum & "','" & OrderItemPartDesc & "','" & OrderItemQty & "','" & OrderItemQtyRec & "','" & OrderItemQtyDtRec & "','" & OrderItemBO & "','" & OrderItemBODt & "','" & OrderItemCanceled & "','" & OrderItemCanceledDt & "','" & OrderItemNotes & "','" & OrderItemPONum & "','" & OrderItemRetailPrice & "','" & OrderItemSalePrice & "','" & Status & "','" & InsertDate & "'" & ")"
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderDate", OrderDate))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderCustomer", OrderCustomer))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderAcctNum", OrderAcctNum))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderType", OrderType))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderSoNum", OrderSoNum))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderItemPartNum", OrderItemPartNum))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderItemPartDesc", OrderItemPartDesc))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderItemQty", OrderItemQty))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderItemQtyRec", OrderItemQtyRec))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderItemQtyDtRec", OrderItemQtyDtRec))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderItemBO", OrderItemBO))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderItemBODt", OrderItemBODt))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderItemCanceled", OrderItemCanceled))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderItemCanceledDt", OrderItemCanceledDt))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderItemNotes", OrderItemNotes))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderItemPONum", OrderItemPONum))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderItemRetailPrice", OrderItemRetailPrice))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("OrderItemSalePrice", OrderItemSalePrice))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("Status", Status))
MyCommand.Parameters.Add(New Odbc.OdbcParameter("InsertDate", InsertDate))
MyCommand.ExecuteNonQuery()
MyConnection.Close()
|
|
|
|
|
Hi there
I wonder if anyone can help me with my problem.
I am building an Programming Editor for my Healthcare Software at work. The editor that comes with it is useless.
One formular i am using notepad to programme has over 20,000 lines of codes. I have started making an editor and the problem is it takes ages to read all the keywords and find the line and add this to a Treeview control. I use Regular Expression to reduce the time to find the keywords. However, i have to loop over each item in the Regular Expression Match Collections in order to find the line where each match occurs. This will enable me to add each keywords and the line number to the tree view control. This loop with my 20,000 lines of codes seems to take ages. Can someone tell me how can i increase the performance? Shall i use Multithreading to do all the looping in the background? However, this will only hide the problems. When the Form appears and the user clicks the treeview structure, the background tasks may not have been completed yet.
Can anyone tells me how to solve this performance problem?
|
|
|
|
|
One way would be to use delegate's to perform the looping. Set the enabled value of the treeview to false and once the looping has finished, set it to true.
This will stop people from clicking on it before you want them to. There are some good tutorials on MSDN for delegating, though not many for placing arguments/paramters in the functions (if someone could let me know one, that would be great, I lost the bookmark and my code when my old HDD died )
As for the faster matching, there isn't an overly fast way to loop over 20,000 lines of an array, you might have to deal with the regex loop searching. I'd have to take a look at the search part of the code to see, though you could try a google hit for 'vb.net text search optimizing'
Daniel
|
|
|
|
|
Hullo,
I'm trying to convert some code from vb6 to .NET. Basically I don't know how to convert this first line so that I can send a string to my printer. I want to use the label printer called "ZebraLP2" (its shared network name). Any help on how to send it this info using VB.NET would be awesome.
Open "\\127.0.0.1" & "\ZebraLP2" For Output As #1
'''Start of EPL2 code
strTemp = "N" & vbCrLf ''' Clear buffer
strTemp = strTemp & "q811" & vbCrLf ''' Label Width in dots (2 inches)
strTemp = strTemp & "Q1217,1" & vbCrLf ''' Label height and gap in dots (1 inch)
strTemp = strTemp & "S" & Trim(Me.strSpeed) & vbCrLf
strTemp = strTemp & "D" & Trim(Me.strDensity) & vbCrLf
strTemp = strTemp & "ZT" & vbCrLf ''' Direction
strTemp = strTemp & "OD" & vbCrLf ''' Direct Thermal mode
strTemp = strTemp & "A25,12,0,4,1,1,N,""" & sFirstLine & """" & vbCrLf
strTemp = strTemp & "A25,45,0,4,1,1,N,""" & sSecondLine & """" & vbCrLf
strTemp = strTemp & "A25,78,0,4,1,1,N,""" & sThirthLine & """" & vbCrLf
strTemp = strTemp & "P" & Trim(intQty)
''' End of the EPL2 code
Print #1, strTemp
Close
-Daniel
|
|
|
|
|
Hmm. I'm not too good with VB6, but this article might help you: Basic Text and Image Printing
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
hmm no that doesn't help me, thats the generic stuff I keep finding when I search for printing help with VB.NET.
The printer is a barcode/label printer and the formatting is very specific so i'm using the EPL2 printing language. Inside that code i have listed it actually controls and handles the print feature. So no print previews, no documents i just need to send a string to this shared printer and it should take care of the rest!
So how do i send a shared printer this string?
|
|
|
|
|
Ok... we do something similar here using VB 6.0 and I have just checked that the following will work with .NET...
1. Write the desired data to a text file.
2. Create a second text file as a .BAT file with the following command: copy \b <your text="" file=""> \\127.0.0.1\ZebraLP2
3. Shell the .BAT file: Shell(<your .bat="" file="">, AppWinStyle.Hide)
Slimy... yes, but, it works.
Tim
|
|
|
|
|
i ran a pretty simple test, and my Zebra Label printer didn't respond at all to running the .BAT file.
Put the first file in folder EPLprint.txt and then ran my .BAT file with the following line:
copy /b EPLprint.txt \\127.0.0.1\ZebraLP2844
...my Zebra Label Printer didn't react. (Yes its on and status is ready) I dunno what I'm doing wrong.
|
|
|
|
|
The "copy /b" just tells the computer to copy a file as binary to the specified network location or device.
Create a text file and send it to a different printer, or, if you can set the printer to be the default, again, from the command prompt, use:
print <file name="">
Tim
|
|
|
|
|
Hi,
I find this site very useful. It is real comprehensive resource for all of us who would like to improve coding skills. Although I searched site in many details I still have some questions with the problem I am trying to solve.
I have developed algorithm for one special task that deals with power flows in power electricity networks. Program works well and I have tested it numerous times but now I would like to build more advanced GUI.
I would like to create some workspace where user could place necessary elements( for example place generators, transformers and connect them with power lines...when they are satisfied with topology they would start the simulation). That is nothing new and looks like workspace in Simulink or any other engineering program.
Since I am not a programmer could you please tell me weather that can be done in VB and how? Also what is the easiest way to complete this? Are there any available solutions?
I am ready to learn but please tell me what I should look for in books and reference manuals.
I hope you understood what I was trying to explain.
Thank you in advance.
Please help!
Kind regards,
Velimir Lackovic
|
|
|
|
|
Hi,
I am also an Electrical Engineer Working as a Programmer.
The task what you said is very easy for telling but it is very difficult for Implimentation. Because as you told it looks like simulation software we need to define each and every block with some sort of Default Data and we need to define some properties to that so that it will act as a block for us for simulations.
i am very happy to see a guy like me and i am also trying to some sort of simulations but i dont have a clear idea of what to do. As you have that idea i think i can help you if you need any help.
And as per my Knowledge this needs Extensive Research and Highly Responsive Algorithm.
Feel free to ask me any thing in this context.
|
|
|
|
|
I don't know why it is so difficult for me to connect to the MySQL database. But I have made a little progress. Data is being inserted to the db but the column names are being inserted instead of the values. Also after the program run for a while I will get the following error:
Can't connect to MySql Server(10048).
Here is some code to go by:
Dim myConnString As String = "DRIVER={MySQL ODBC 3.51 Driver};" & _
"SERVER=192.168.1.27;" & _
"DATABASE=;" & _
"USER=;" & _
"PASSWORD=;" & _
"OPTION=3;"
Dim MyConnection As New Odbc.OdbcConnection(myConnString)
MyConnection.Open()
Dim MyCommand As New Odbc.OdbcCommand
MyCommand.Connection = MyConnection
MyCommand.CommandText = "INSERT INTO ls_orderitems (OrderItemID, OrderDate, OrderCustomer, OrderAcctNum, OrderType, OrderSoNum, OrderItemPartNum, OrderItemPartDesc, OrderItemQty, OrderItemQtyRec, OrderItemQtyDtRec, OrderItemBO, OrderItemBODt,OrderItemCanceled, OrderItemCanceledDt, OrderItemNotes, OrderItemPONum, OrderItemRetailPrice, OrderItemSalePrice, Status, InsertDate) VALUES('OrderItemID', 'OrderDate', 'OrderCustomer', 'OrderAcctNum', 'OrderType', 'OrderSoNum', 'OrderItemPartNum', 'OrderItemPartDesc', 'OrderItemQty', 'OrderItemQtyRec', 'OrderItemQtyDtRec', 'OrderItemBO', 'OrderItemBODt','OrderItemCanceled', 'OrderItemCanceledDt', 'OrderItemNotes', 'OrderItemPONum', 'OrderItemRetailPrice', 'OrderItemSalePrice', 'Status', 'InsertDate')"
MyCommand.ExecuteNonQuery()
MyConnection.Close()
jds1207
jds1207
|
|
|
|
|
jds1207 wrote: MyCommand.CommandText = "INSERT INTO ls_orderitems (OrderItemID, OrderDate, OrderCustomer, OrderAcctNum, OrderType, OrderSoNum, OrderItemPartNum, OrderItemPartDesc, OrderItemQty, OrderItemQtyRec, OrderItemQtyDtRec, OrderItemBO, OrderItemBODt,OrderItemCanceled, OrderItemCanceledDt, OrderItemNotes, OrderItemPONum, OrderItemRetailPrice, OrderItemSalePrice, Status, InsertDate) VALUES('OrderItemID', 'OrderDate', 'OrderCustomer', 'OrderAcctNum', 'OrderType', 'OrderSoNum', 'OrderItemPartNum', 'OrderItemPartDesc', 'OrderItemQty', 'OrderItemQtyRec', 'OrderItemQtyDtRec', 'OrderItemBO', 'OrderItemBODt','OrderItemCanceled', 'OrderItemCanceledDt', 'OrderItemNotes', 'OrderItemPONum', 'OrderItemRetailPrice', 'OrderItemSalePrice', 'Status', 'InsertDate')"
jds1207 wrote: Data is being inserted to the db but the column names are being inserted instead of the values.
Did you happen to look at what's in the VALUES clause?? It's inserting the Column names because that exactly what your telling it to do! VALUES ('OrderItemID', 'OrderDate', ... You've told it to insert these strings into the database. You have to build the SQL statement to insert the data you have stored in variables somewhere, preferrably using a parameterized query.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|