|
You have a problem. What does this input number represent?? Is this the number of seconds since a specified date?
Without knowning this, it's impossible to translate the code. Java's Date class starts at Jan 1, 1970. VB6 doesn't really have a Date class, but can handle dates in a much greate range, depending on the representation and the functions used.
|
|
|
|
|
Hi
i understand ur confusion ,
here they are taking millisconds
|
|
|
|
|
OK. Since Java's epoch starts at Midnight, Jan 1, 1970, add the number of seconds to this date/time:
newDate = DateAdd("s", (milliseconds / 1000), "01-Jan-1970")
|
|
|
|
|
Hi
thx ur reply but here i want display date like dd/mm/yyyy
plz give me reply
|
|
|
|
|
Nothing in the code I submitted displays the date in any way.
So, you have to supply the code to return a string with the formatted date yourself. Like using the FormatDateTime[^] function, or using your own custom format string in the Format[^] function.
|
|
|
|
|
Hi
thx for solved the problem
|
|
|
|
|
Currently, I'm working on altering an image processing application to accept 8-bit instead of 32-bit images. The problem that I'm currently having is replacing the drawImage method. Currently, I've been investigating BitBlt to draw these 8-bit images to no avail. drawImage requires a 32-bit image, and for all examples of BitBlt in VB.NET it seems that you need to use the method Graphics.fromImage(), which also requires a 32-bit image. Is there any way to draw an 8-bit image using VB.NET? Thanks in advance.
|
|
|
|
|
You're wrong. You can create an image of any bit depth you like. Your image processing options will be seriously limited in 256 color, unless the image is greyscale, then it will be fine. Your best option really is to process in 32 bit ( and, to be honest, it's a ton easier to be stuffing the right colors into each pixel than looking them up in a palette and worrying about if you have any options left or need to figure out two colors you can merge to a single value ), and then converting at the end, which is as a easy as creating an 8 bit image, and drawing your 32 bit image onto it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi!
I have a cuestion, in vb6 the errors are handle by on error statement, he is very good error handle, but i would like can get more information about error than the err.description, who i think is more simple.
I would programming my error handle similar to firefox error handle wich show the line error, the html code error line, error line reason, etc, i believe what not exist in error handle basic
Thanks very much for your help
Sorry: you could tell me if this is possible but using api because i working in access with vb to applications please, thanks
-- modified at 11:52 Thursday 14th June, 2007
|
|
|
|
|
The errorhandling in VB6 is actually pretty primitive and cannot supply the information you want. There is no API call you can make either since those API calls are already made by the VB6 runtime to get the information it's already giving you.
About the only thing you can get is the message, the line number, and the module where the error occured. There's nothing you can do to get any more information about what caused the error.
|
|
|
|
|
oops...ok, thanks very much for your help
|
|
|
|
|
Does any one know how to search for files using recursive directory info? I need to be able to start at C:\ and search through the entire drive. The code I have now only search within folders.
Here is my code:
'Declare variable.<br />
Dim dDir As DirectoryInfo<br />
Dim fFound As Boolean = False<br />
<br />
'Search directory for files and add to the listbox.<br />
For Each sDir As String In dirs<br />
If Not Directory.Exists(sDir) Then Continue For<br />
dDir = New DirectoryInfo(sDir)<br />
For Each ext As String In patterns<br />
For Each fi As FileInfo In dDir.GetFileSystemInfos("*." & ext)<br />
For Each item As Object In ListBox2.Items<br />
If Convert.ToString(item) = fi.Name Then<br />
fFound = True<br />
End If<br />
Next<br />
If fFound = False Then<br />
ListBox1.Items.Add(fi.Name)<br />
Else<br />
'Reset fFound<br />
fFound = False<br />
End If<br />
Next<br />
Next<br />
Next
Please Help!
jds1207
|
|
|
|
|
Examine this example from Jesse Liberty's Programming C# book. Then adapt it for VB. Note the recursive call to ExploreDirectory().
namespace Programming_CSharp
{
using System;
using System.IO;
class Tester
{
public static void Main( )
{
Tester t = new Tester( );
string theDirectory =
Environment.GetEnvironmentVariable("SystemRoot");
DirectoryInfo dir = new DirectoryInfo(theDirectory);
t.ExploreDirectory(dir);
Console.WriteLine(
"\n\n{0} files in {1} directories found.\n",
fileCounter,dirCounter);
}
private void ExploreDirectory(DirectoryInfo dir)
{
indentLevel++;
for (int i = 0; i < indentLevel; i++)
Console.Write(" ");
Console.WriteLine("[{0}] {1} [{2}]\n",
indentLevel, dir.Name, dir.LastAccessTime);
FileInfo[] filesInDir = dir.GetFiles( );
foreach (FileInfo file in filesInDir)
{
for (int i = 0; i < indentLevel+1; i++)
Console.Write(" ");
Console.WriteLine("{0} [{1}] Size: {2} bytes",
file.Name,
file.LastWriteTime,
file.Length);
fileCounter++;
}
DirectoryInfo[] directories = dir.GetDirectories( );
foreach (DirectoryInfo newDir in directories)
{
dirCounter++;
ExploreDirectory(newDir);
}
indentLevel--;
}
static int dirCounter = 1;
static int indentLevel = -1;
static int fileCounter = 0;
}
}
Kevin
|
|
|
|
|
Hi I'm writing a service in VB6 which will restart another service of it is hanging. I figure I can use QueryServiceStatus to retrieve the status.
The thing is, if the other service has crashed, then what will the status be? I have a feeling it will be SERVICE_RUNNING, in which case I will not be able to tell whether it has crashed. Does anyone have any ideas on how I can find out if my service is responsive?
Private Const SERVICE_STOPPED = &H1<br />
Private Const SERVICE_START_PENDING = &H2<br />
Private Const SERVICE_STOP_PENDING = &H3<br />
Private Const SERVICE_RUNNING = &H4<br />
Private Const SERVICE_CONTINUE_PENDING = &H5<br />
Private Const SERVICE_PAUSE_PENDING = &H6<br />
Private Const SERVICE_PAUSED = &H7<br />
Private Const SERVICE_ACTIVE = &H1<br />
Private Const SERVICE_INACTIVE = &H2
Before anyone tells me to fix the other service, I cannot as the company that wrote it is bust, Cheers!
|
|
|
|
|
topherino wrote: The thing is, if the other service has crashed, then what will the status be?
The behavior is undefined. It depends on who the service crashed and if it's even still capable of responding to the SCM. If it IS still responding, but the worker thread(s) in the service have crashed, well, there's no way for the SCM to know that unless the service code can tell if it's own worker threads have died. If it can't, it'll tell the SCM everything is just peachy!
These status codes are only reliable if the service is responding and working normally AND is properly coded to monitor it's own worker threads. If not, none of these status code mean a bloody thing.
topherino wrote: Before anyone tells me to fix the other service, I cannot as the company that wrote it is bust,
Hmmm. I wonder why that is... I'd start looking for a replacement for this service if at all possible.
|
|
|
|
|
So how does the SCM interrogate the service? What function is called on the service?
|
|
|
|
|
In a .NET Framework Service, you don't get access to this function. It gets regsitered with the SCM and is called ServiceControlCallback or ServiceControlCallbackEx.
|
|
|
|
|
Sorry, what I meant to ask was:
How do I implement and expose a function to the SCM which can return a SERVICE_STATUS struct?
|
|
|
|
|
If your service is based on the ServiceBase class, you don't. It's already registered when your service is launched. The ServiceBase class does not let you override any of it's members. You don't get the opportunity to replace it's functionality at all. Like I said, that stuff is maintained internally by the ServiceBase class.
You'd have to rewrite your service entirely on your own, supplying ALL the functionality that the ServiceBase class takes care of for you, but replacing the piece that registers the service control callback with your own function.
Google for ".NET Reflector" and download it. Open up the System.ServiceProcess.dll, then drill down to the ServiceBase class. This is what you'd have to rewrite. You'd mak your modifications to the Run method. Notice that most of the class is Private and not overridable. This is what's stopping you from replacing the piece you need.
The ServiceBase class is not only a wrapper for your service, but is also a buffer that insulates your service from the large amount of code between your service and the SCM.
Now, the problem is, this is all moot because you cannot replace the callback for the original service that you're trying to get a status for. It will STILL be registered and STILL return bogus status information.
|
|
|
|
|
hello dotnetians,
I'v to do an application through which a xml file has to be read,and to be written into excel, i'm using vb.net 2.0,
as i'm freasher so do'nt know how to proceed,
So, providing any code(badly needed),or any other help (ASAP) would be
appreciated .
thanx..........Be_Aman
|
|
|
|
|
Noone is going to write the code for you. You have to write it yourself and when you get stuck, you can ask specific questions.
Excel 2003 and above will already import XML data without any code from you. All you have to do is File, Open...
But, if you have to write the code to do this, you'll need to brush up on reading an XML file, parsing the data, and doing Excel Interop.
There are various ways of reading an XML file. If the number of records is not known, but can be large, then an XmlReader[^] would probably be appropriate.
There's tons of example of doing Excel Interop on the web. The problem is the Excel object model isn't exactly the easiest thing to learn. All you have to do is Google for "vb.net excel interop[^]".
|
|
|
|
|
I'm working with Microsoft Access, using VBA, and I want to be able to click on an item in a ListBox, then use the AfterUpdate() Sub-routine for that ListBox control, and be able to store that value into a String variable. My loop is as follows:
***START***
Private Sub Descriptions_lst_AfterUpdate()
Dim iterator As Integer
Dim descriptionName As String
'ListBox name is simply Descriptions_lst
For iterator = 0 to Descriptions_lst.ListCount - 1
If Descriptions_lst.Selected(iterator) Then
descriptionName = Descriptions_lst.Column(0, iterator)
End if
Next iterator
***END***
The loop is working correctly, however, the 'if' statement is not evaluating to true, so I therefore cannot test to see if the code inside the 'if' statement is even valid in retrieving the String equivalent for the selected item. Any ideas?
|
|
|
|
|
I think you want to use the Click event, not AfterUpdate. AfterUpdate only fires after any change in the controls data. Selecting items in the ListBox does not fire the AfterUpdate event.
|
|
|
|
|
Its weird though, If I put Message Boxes throughout the code, everytime I click, it actually does fire the AfterUpdate() event.
For example, I placed a MsgBox inside the loop but outside the if statement to check to see if the loop is working: MsgBox "loop works".
Then I placed a MsgBox inside the if statement: MsgBox "if works"
Then I placed a MsgBox inside the event, but after the loop executes: MsgBox "post loop works"
I get "loop works" and "post loop works" to come up, but not "if works".
So its having troubles verifying my selected item. There are two Selected properties (one in Access, and one in MSForms). The default one when I write my code seems to come up with the Access Selected version. The thing I think is the issue here is, this returns a Long value...you would think Boolean. However, the MSForms version of Selected under a ListBox returns a Boolean...I just can't figure out how to call that version of it. It seems to always call the Access version.
With this extra information, do you have any ideas? Thanks again Dave.
|
|
|
|
|
If it's an Access Form ListBox, the it will call the Access version. Period. You cannot change that. According to the docs, ListBox.Selected(index) takes a Long (32-bit signed integer) as an arugment and returns a Boolean if that item is selected or not.
Does the selection highlight disappear after your AfterUpdate code runs?? If it does, then AfterUpdate fires AFTER the data is changed and the selections are removed. In which case, yes, all of your "is selected?" compares will return false.
|
|
|
|
|