|
Nick Otten wrote: The error on the printer is coused by the speed and ammount of print job is has
to swallow. if i print a file with the same amount of pages its not really a
problem. I already updated the firmware to the newest version and even contacted
Xerox for help. but they said the machines are just not made to handle printer
tasks at the speed i send them.
That's a load of horse sh*t. The speed of the jobs is dictated by the printer, not the application. The printer signals it's ready and idle to its driver on the print server (the client machine) and the spooler sends the next job.
The spooler is insulating the printer from the applications print jobs. You can send as many jobs as you want as fast as you want. They all get sent to the spooler, not the printer. The printer won't know anything about it at all.
This is definitely a problem for Xerox to fix, not you.
Wanna try it? Swap the printer out, install the drivers and try your app unmodified on a different printer.
|
|
|
|
|
Well that's Xerox for you i guess. Or perhaps i just had a "first day helpdesk" person on the line i don't know, nor did i really care. It didn't work, they gave me that explanation. And with that it was pretty clear they didn't have a fix. Also printers aren't my responsibility so i didn't pay more attention to it.
fact remains that this app was initially written for 2 people in less then a hour to print like 10 forms in a weak. I choose to use excel instead of crystal reports because users "know" how to make something in excel, while crystal reports is the scary unknown for them. Gues it was a big mistake tough, its coming back at me pretty bad now.
|
|
|
|
|
Nick Otten wrote: I got a program that prints production forms using excel
Here is your problem - excel as a reporting tool. Wrong tool for the job.
Instead of busting your balls trying to make excel do something it is fundamentally not designed to do, spend the time rewriting the printing solution to something designed to do that job.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
The program was initially written for 2 people in less then a hour to print like 10 forms in a weak. I choose to use excel instead of crystal reports because users "know" how to make something in excel, while crystal reports is the scary unknown for them.
Now however more users found out of this tool and some are using it for things it isn't really designed for. I asked my initial question to see if i could "boost" the program a bit to make it work. but i guess im just gone shake my first to them telling them they are abusing software/blocking them access.
|
|
|
|
|
Nick Otten wrote: Now however more users found out of this tool and some are using it for things it isn't really designed for
You know the reward for good work right!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I'm stumped.
I tried translating a class in c# to vb, and I'm stuck on this function.
For some reason, it's not looping around enough, to get the desired result.
So the input array is 0 0 6 089 0 0 12 176
and the output of converted is suppose to be "0000000000000000000001100101100100000000000000000000110010110010"
but I get 000000000000
Private Function ByteArrayToBitString(ByVal byteArray() As Byte) As String
Dim idx As Integer = 0
Dim jdx As Integer = 0
Dim newByteArray() As Byte = New Byte(byteArray.Length - 1) {}
Array.Copy(byteArray, newByteArray, byteArray.Length - 1)
Dim converted As String = ""
For idx = 0 To newByteArray.Length - 1
For jdx = 0 To 7
converted += If((newByteArray(idx) And &H80) > 0, "1", "0")
newByteArray(idx) <<= 1
jdx += 1
Next
idx += 1
Next
Return converted
End Function
I took out the code, to test the loop counts, and it comes up short on jdx, and the idx loops around 8 times.
I must of made a stupid mistake somewhere, but I can't figure where. Just looking for other eyes on the code, because I don't see it, perhaps my translation is wrong somewhere, but you should be able to get the idea.
|
|
|
|
|
jkirkerx wrote: the loop counts, and it comes up short on jdx, and the idx loops around 8 times.
It's doing what it looks like coded. Can you share your C# code? And a line on what is it doing?
|
|
|
|
|
I figured out the loop count, forgot for increments the counter automatically, so I had double increments. So that function is fixed now, I get the correct value string.
Now I'm stuck on this this function, I'm pretty close now, just the width is wrong, double the correct value, should be 650x325. Without the input stream, how would you know.
Sorry to post so much code, Trying to convert this
Sub Page Load()
Dim swf As SwfParser = New SwfParser
Dim swfRect As Drawing.Rectangle = New Drawing.Rectangle
swfRect = swf.get_SWF_Dimensions("p:/flash/Bowling_Jazz_Collection.swf")
Dim iWidth As Integer = swfRect.Width 'suppose to be 625, but is 1300
Dim iHeight As Integer = swfRect.Height 'I got this right 325
swf = Nothing
End Sub
public class SwfParser
{
public Rectangle GetDimensions(String filePath)
{
using (FileStream stream = File.OpenRead(filePath))
{
return GetDimensions(stream);
}
}
public Rectangle GetDimensions(Stream stream)
{
Stream inputStream = null;
byte[] signature = new byte[8];
byte[] rect = new byte[8];
stream.Read(signature, 0, 8);
if ("CWS" == System.Text.Encoding.ASCII.GetString(signature, 0, 3))
{
inputStream = new InflaterInputStream(stream);
}
else
{
inputStream = stream;
}
inputStream.Read(rect, 0, 8);
int nbits = rect[0] >> 3;
rect[0] = (byte)(rect[0] & 0x07);
String bits = ByteArrayToBitString(rect);
bits = bits.Remove(0, 5);
int[] dims = new int[4];
for (int i = 0; i < 4; i++)
{
char[] dest = new char[nbits];
bits.CopyTo(0, dest, 0, bits.Length>nbits ? nbits : bits.Length);
bits = bits.Remove(0, bits.Length > nbits ? nbits : bits.Length);
dims[i] = BitStringToInteger(new String(dest)) / 20;
}
return new Rectangle(0, 0, dims[1] - dims[0], dims[3] - dims[2]);
}
private int BitStringToInteger(String bits)
{
int converted = 0;
for (int i = 0; i < bits.Length; i++)
{
converted = (converted << 1) + (bits[i] == '1' ? 1 : 0);
}
return converted;
}
private String ByteArrayToBitString(byte[] byteArray)
{
byte[] newByteArray = new byte[byteArray.Length];
Array.Copy(byteArray, newByteArray, byteArray.Length);
String converted = "";
for (int i = 0; i < newByteArray.Length; i++)
{
for (int j = 0; j < 8; j++)
{
converted += (newByteArray[i] & 0x80) > 0 ? "1" : "0";
newByteArray[i] <<= 1;
}
}
return converted;
}
}
This is my conversion
Public Class SwfParser
Public Function get_SWF_Dimensions(ByVal filePath As String) As Rectangle
Dim fileLength As Long = 0
Dim stream As FileStream = New FileStream(filePath, FileMode.Open, FileAccess.Read)
Dim fsLen As Long = stream.Length
Dim rec As Rectangle = getDimensions(stream)
End Function
Private Function getDimensions(ByVal stream As Stream) As Rectangle
Dim inputStream As Stream = Nothing
Dim signature() As Byte = New Byte(8) {}
Dim rect() As Byte = New Byte(8) {}
stream.Read(signature, 0, 8)
If (System.Text.Encoding.ASCII.GetString(signature, 0, 3) = "CWS") Then
inputStream = New InflaterInputStream(stream)
Else
inputStream = stream
End If
inputStream.Read(rect, 0, 8)
Dim nbits As Integer = rect(0) >> 3
rect(0) = rect(0) And &H7
Dim bits As String = ByteArrayToBitString(rect)
bits = bits.Remove(0, 5)
Dim dims(4) As Integer
For idx As Integer = 0 To 3
Dim dest() As Char = New Char(nbits) {}
bits.CopyTo(0, dest, 0, If(bits.Length > nbits, nbits, bits.Length))
bits = bits.Remove(0, If(bits.Length > nbits, nbits, bits.Length))
dims(idx) = BitStringToInteger(New String(dest)) / 20
Next
Return New Rectangle(0, 0, dims(1) - dims(0), dims(3) - dims(2))
End Function
Private Function BitStringToInteger(ByVal bits As String) As Integer
Dim converted As Integer = 0
For idx As Integer = 0 To bits.Length - 1
converted = (converted << 1) + If(bits(idx) = "1", 1, 0)
Next
Return converted
End Function
Private Function ByteArrayToBitString(ByVal byteArray() As Byte) As String
Dim newByteArray() As Byte = New Byte(byteArray.Length - 1) {}
Array.Copy(byteArray, newByteArray, byteArray.Length - 1)
Dim converted As String = ""
For idx As Integer = 0 To newByteArray.Length - 1
For jdx As Integer = 0 To 7
converted += If((newByteArray(idx) And &H80) > 0, "1", "0")
newByteArray(idx) <<= 1
Next
Next
Return converted
End Function
End Class
|
|
|
|
|
Try:
Private Function BitStringToInteger(ByVal bits As String) As Integer
Dim converted As Integer = 0
For idx As Integer = 0 To bits.Length - 1
converted = (converted << 1) + If(bits(idx) = "1"C, 1, 0)
Next
Return converted
End Function
|
|
|
|
|
I'll give that a try Friday
For some reason, bits that is passed into the function, is 1 too long, in other words, the length is 1 bit bigger than it's suppose to be.
So I did a -2 on the length in the loop instead of -1, and the value is now correct. It's sloppy, just a band-aid, but overall in the end, the return value is correct.
I would like to fix it correctly, so let me give your fix a test in the morning.
Good job on isolating it down to that function, and thanks for helping me out Sandeep.
Private Function BitStringToInteger(ByVal bits As String) As Integer
Dim converted As Integer = 0
For i As Integer = 0 To bits.Length - 2 '<- chopped it down 1 more
converted = (converted << 1) + If(bits(i) = "1", 1, 0)
Next
Return converted
End Function
|
|
|
|
|
Hello,
I'm not sure but i think this would do the trick
dim output as string = System.Text.Encoding.Unicode.GetChars(your_byte_array)
hope it helps!
edit: oeps didn't see you already fixed it, never mind that i said something
modified 21-Jun-12 9:19am.
|
|
|
|
|
Is there a way that i can make a class to store passwords from my form1 or form2 to the Windows 7 Registry or a spot on the local Drive?
Public Class Form1
My.Computer.FileSystem.WriteAllText("C:\Pass\PasswordLog.txt", TextBoxLog.Text, True)
End Sub
End Class
or
SOME way to store in the registry... what would the code be for this ?
i tried and failed bad im sure... im a noob with VB but here is what i have for my class that stores passwords in the registry ....
<pre lang="vb">
Imports Microsoft.Win32
' Reads and writes the top three high scores to the registry.
Public Class Passwords
Shared Password As Integer
''' Read Passwords from the registry.
Public Shared Function GetPasswords() As Password()
Dim tops(1) As Password
Dim passKey As RegistryKey = Registry.CurrentUser.CreateSubKey("Software\VBSamples\Collapse\Passwords")
For index As Integer = 0 To 1
Dim key As String = "place" & index.ToString
Dim password As New Password(CStr(passKey.GetValue(key)))
tops(index) = password
Next
passKey.Close()
Return tops
End Function
' Update and write the Passwords.
Public Shared Sub UpdatePasswords(ByVal Password As Integer)
Dim tops(1) As Password
Dim passKey As RegistryKey = Registry.CurrentUser.CreateSubKey("Software\VBSamples\Collapse\Passwords")
tops(0) = New Password(passKey.GetValue("Place0").ToString)
If Password > tops(0).Password Then
Dim name As String = InputBox("New Password " & Password)
tops(1) = New Password("")
tops(1).Password = Password
Array.Sort(tops)
Array.Reverse(tops)
passKey.SetValue("Place0", tops(0).ToString)
End If
passKey.Close()
End Sub
' Set up the entries for new Passwords.
Shared Sub SetUpPasswords()
Dim passKey As RegistryKey = Registry.CurrentUser.CreateSubKey("Software\VBSamples\Collapse\Passwords")
If passKey.GetValue("Place0") Is Nothing Then
passKey.SetValue("Place0", "")
End If
passKey.Close()
End Sub
' Reset Passwords.
Shared Sub ResetPasswords()
Dim passKey As RegistryKey = Registry.CurrentUser.CreateSubKey("Software\VBSamples\Collapse\Passwords")
passKey.SetValue("Place0", "")
passKey.Close()
End Sub
End Class
For the Form1 or Form2 i was thinking something like :
Public Class Passwordz
Private Sub Passwordz_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.DataGrid1.DataSource = HighScores.GetHighScores()
End Sub
Private Sub resetPasswords_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles resetScores.Click
Passwords.ResetPasswords()
Me.DataGrid1.DataSource = Passwords.GetPasswords()
End Sub
End Class
</pre>
my Questions here is would something like this work and how would i go about doing it?
If you would like credit for any code you provide please say so and ill add your name on the project.
-- modified 18-Jun-12 13:41pm.
|
|
|
|
|
I'm kinda wondering why you're using passwords at all if you're happy to have them stored unencrypted in full public view?
|
|
|
|
|
thats a good question . i've only been doing VB for almost a year now off n on. I can make it encrypted myself if i wanted so that is not my issue at the moment but if anyone wants to add it into the class please feel free to do so.
thank you
|
|
|
|
|
Ok, I've now looked through your commented code and see that the scenario may be rather different than how I first imagined it. Firstly, I don't think you mean 'password' but 'user name' which is rather different! Anyway, I can't see any great value in writing this kind of detail to the registry and certainly not to CURRENT_USER as presumably it is possible that the program (a game, I assume?) might be operated by several people using different log-on accounts. The best answer by far would be to set up a small database to read and write from.
|
|
|
|
|
yes its ment for a game but i would like to use it for other things too if possible.
how would i set up a small database to read and write from ?
Please Keep in Mind if you explain it to me...
im still new to VB even though ive been doing it almost a year .... i have only done super simple projects and now im trying to challenge myself to see if i can do better stuff or not. I make things for people i know in person so i can hand them the project on a flash drive. I Hope to get good enough to write something like Microsoft paint in VB not C# or C++ or any other language at the moment. I do want to learn C# one day just waiting till im up to intermediate/Advanced level with VB so as to not get too far ahead of myself.
idea of my skill level if it helps. I wrote my own tic-tac-toe game to play against myself. if i went in spot 1 it would auto move to spot 2,4, or 5 and if i move to spot 5 first it would move to spot 1,2,3,4,5,6,7,8, or 9. it all depends on where i move for its next move.... not the best work ive made but almost.
please dont use big o' computer programmer word(s) i have to google to know what they mean unless you cant help yourself.
Thank you and ill be waiting for a reply
|
|
|
|
|
I got ticked off yesterday for not using big ol' computer words. You just can't win!
Are you using VB Express or the full Visual Studio version?
modified 21-Jun-12 19:29pm.
|
|
|
|
|
Ok, here we go. All the code you need to set up a simple database and a subroutine to add new records to which you can pass values without the need to change any existing code. You need to add a DataGridView for display. It's not the most elegant but it's the easiest to set up. When you're familiar with the code you can try something more sophisticated.
Imports ADOX
Public Class Create
Dim DBSet As New DataSet
Dim DBAdaptor As OleDb.OleDbDataAdapter
Dim DBTable As DataTable
Dim DBView As DataView
Dim DBCon As New OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = ScoreDB.mdb")
Dim DBCommand As OleDb.OleDbCommandBuilder
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
If Not My.Computer.FileSystem.FileExists("ScoreDB.mdb") Then
Dim DBCat As New Catalog()
DBCat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=ScoreDB.mdb;" & _
"Jet OLEDB:Engine Type=5")
Dim DBCmd As New OleDb.OleDbCommand("CREATE TABLE [High_Score] ([Name] TEXT(30), [Score] NUMERIC(10))", DBCon)
DBCon.Open()
DBCmd.ExecuteNonQuery()
DBCon.Close()
End If
DBCon.Open()
Dim DBAdaptor As New OleDb.OleDbDataAdapter("SELECT * FROM High_Score", DBCon)
DBAdaptor.Fill(DBSet, "High_Score")
DBCon.Close()
Dim DBView As New DataView(DBSet.Tables(0))
DBView.Sort = "Score DESC, Name ASC"
DataGridView1.DataSource = DBView
End Sub
Private Sub DataUpdate(ByVal Name As String, Score As Integer)
Dim DBAdaptor As New OleDb.OleDbDataAdapter("SELECT * FROM High_Score", DBCon)
Dim DBCommand As New OleDb.OleDbCommandBuilder(DBAdaptor)
Dim DBRow As DataRow
DBRow = DBSet.Tables("High_Score").NewRow()
DBRow.Item("Name") = Name
DBRow.Item("Score") = Score
DBSet.Tables(0).Rows.Add(DBRow)
DBAdaptor.Update(DBSet, "High_Score")
End Sub
End Class
|
|
|
|
|
Sorry i've been away awhile.
Thank you For the help i will use this and try to become familiar with your code. After i'm familiar with your code i will try to make one of my own similar to yours if possible.
[SOLVED]
|
|
|
|
|
I use the FULL Visual Studio Version . soo glad i got it a long time ago it said $11,000 on the Ultimate Version on it the other day.... i was like WTF!!?? when did that happen lol but yes i have the full version and it works Great.
|
|
|
|
|
Hi people
I have a desktop vb.application that make a logon on to a server application.
In case of successfull logon session is set (or at least I suppose it is). This code is a webservice public function linked to VB.NET as webservice Reference
Public Function Login_Click(stringa, azienda)
Dim conn As OdbcConnection
Dim comm As OdbcCommand
Dim dr As OdbcDataReader
Dim Sql As String = stringa
Dim ritorno As Boolean = False
conn = New OdbcConnection(connectionString)
Try
conn.Open()
comm = New OdbcCommand(Sql, conn)
dr = comm.ExecuteReader()
ritorno = dr.Read
If dr.Read() Then
'create sessions
Session("ID") = dr.GetString(0) *That's the userid
Session("DateTime") = DateTime.Now.ToString()
Session("company") = azienda
Session("blacklist") = dr.GetString(2)
End If
Now, from another VB.NET application I wish to check the users who logged on. So as webservice reference I tried something like this, but it doesn't work:
<webmethod()> _
Public Function checkSession(id) As Boolean
Dim answer As Boolean
MsgBox(Session.Item(id))
If Session.Item(id) Is id Then
answer = True
Else
answer = False
End If
Return answer
End Function
My expectation was that VB.NET application get the user state, but an error happens.
Regardless my implementation, any suggestion from you in order to get the information that i need ?
Anybody so kind to give me an hand ?
Thanks a lot \\ Antonio
|
|
|
|
|
There is no such thing as a Session in a desktop app.
You can create your own implementation of this though. Your logins would have to be stored in a database of some kind. Off the top of my head, the application sends the username and password to your server code when it is authenticated. If it passes authentication, it sends back a GUID that is also logged into the database as being an active login.
Once you have that data, your other app can request all the active logins from the database.
Your server code will also have to implement a logout method to remove the GUID passed to the client. The client could just pass the GUID to let it know it wants to log out.
Your server code will also have to maintain the active login database by clearing out stale records where a timeout value has expired. Theis prevents the database from being loaded up with dead login data where the client logged in, but never logged out for some reason.
|
|
|
|
|
Hi Dave
Thanks a lot for your reply.
I was supposing that session stuff doesn't require any interwork with db. If I store into the DB my loggin state it's much easer but it doesn't sound as implementation of session functionality either.
Please forgive me, I suck as designer, but I supposed that session functionality allows the user to keep available information without accessing to the DB.
Regarding timeout, how can I keep track of inactive users logged in my DB without a session mechanism ?
I suppose that I should implement a sort of tread which performs a continuos scan of users table.
Honestly, I'm a bit surprise because I belived that to start a session from 1 side using a webreference class which set 'session("my_session")=1' was enough.
The other desktop application use another webreference class which can read the state of a specific session if this way
'if session("my_session")=1
return true
Most probably session mechanism works very differently of my understanding
|
|
|
|
|
ilgrongo wrote: I belived that to start a session from 1 side using a webreference class which
set 'session("my_session")=1' was enough.
Desktop apps have no such concept as a "session". They only exist in web applications (ASP.NET) and that mechanism can be used by web services to manage session state.
For a web service, sessions do exist. But, session data (and the "Session" object) only exist in the server-side code. The desktop application cannot reference Session at all.
|
|
|
|
|
Thanks again Dave
Sorry It was my fault, sometime I can't express myself properly.
So far,I didn't write a single line of code desktop side trying to manage session, modificate session data and so on.
What I'm struggling with is just the retriving of session information from server side to be used.
On desktop side I'm writing code like this:
Dim webConsumer As New localhost.WebService1
If webConsumer.checkSession(userid) = 1 Then
.....do something.........
Where webConsumer is the instance of object WebService1
Thanks a lot
|
|
|
|
|