| Rename files (remove last few random numbers) |
|
 |
Index ‹ Visual Studio ‹ Visual Basic
|
- Previous
- 1
- Visual Basic >> Problem in Binary To Double Conversion in Win2000 which is working fine in WinXPHai,
I am trying to convert a binary value to double using the function
'pblfBinaryToDouble' given below. I am getting the result correctly in
Windows XP, but an 'Overflow Error' in Windows 2000. Can any one please help
me to solve this problem? What may be the issue, should I run any service
pack in Windows 2000 or something else?
The problem I am facing is in:
Microsoft Windows 2000
5.00.2195
Service Pack 4
Microsoft VisualBasic 6.0
Sample Output which I am getting in WindowsXP:
x = chr(0) & chr(0) & chr(182) & chr(69) & chr(102) &chr(102) & chr(6) &
chr(160)
?x
¶Eff
?pblfBinaryToDouble(x)
200409186961056
The functions used are given below.
Thanks & Regards,
Uma
Public Function pblfTwiddle(ByVal svInput As String) As String
Dim lngCount As Long
Dim svResult As String
svResult = ""
pblfTwiddle = svResult
For lngCount = Len(svInput) To 1 Step -1
svResult = svResult + Mid(svInput, lngCount, 1)
Next
pblfTwiddle = svResult
End Function
Public Function pblfBinaryToDouble(ByVal svBinaryValue As String) As Double
Dim lngLength As Long
Dim lngCount As Long
Dim svHex As String
Dim dblResult As Double
dblResult = 0#
pblfBinaryToDouble = dblResult
svBinaryValue = pblfTwiddle(svBinaryValue)
lngLength = Len(svBinaryValue)
svHex = "&H"
For lngCount = lngLength To 1 Step -1
svHex = svHex & IIf(Len(Hex(Asc(Mid(svBinaryValue, lngCount, 1)))) =
1, "0", "") & Hex(Asc(Mid(svBinaryValue, lngCount, 1)))
Next lngCount
dblResult = CDbl(svHex)
pblfBinaryToDouble = dblResult
End Function
- 2
- Visual Studio C++ >> CString::AllocSysString() needs to be free'd?Hello!
I'm using VC++ 7.0 (.net 2002) and MFC.
I have a function (foo) that uses a CString variable (strCommand) as a
parameter. foo is accessing a database via ADO. Among the code is this:
pCommand->put_CommandText(strCommand.AllocSysString());
Do I need to free the memory allocated to string or will it do so
automatically?
// Anders
Crossposted to: microsoft.public.dotnet.languages.vc,microsoft.public.vc.language,microsoft.public.vc.mfc
Replies will go to: microsoft.public.dotnet.languages.vc
- 3
- VB Scripts >> Remotable WSC not showing up in "dcomcnfg.exe" ?Hi there,
maybe someone could help me in this corner:
- I created a WSC (a COM component with the logic written in VBasic and ooRexx), which can be
instantiated locally *and* after some research and peeking and poking also remotely (one needs to
use the "remotable"-attribute and then configure the remote access via "dcomcnfg.exe"
- after enhancinge, changing, copying forward and backward, renamed the PROGID and the like; anyway,
locally everything has been working and humming along nicely, but now when trying to test the
remote-instantiation and remote access I need to configure the DCOM part for that WSC; unexplicably,
the WSC-component does not show up anymore? Tried a lot of things (including rebooting the machine a
couple of times just to be sure), but so far I could not come to a solution.
If there is anyone who could give any hints/ideas, I really would appreciate it.
TIA,
---rony
P.S.: Could it be that NTFS-access rights can have an influence on "dcomcnfg.exe" not being able to
find my WSC-component ? (To fight that, I allowed full access to "Everyone" on that particular
directory tree, but who knows?)
- 4
- 5
- Visual Basic [VB] >> Changing Printer's default paperHi all,
I am trying to print a report in A4 paper, but my printer's default paper is
different (Letter 8.5 x 11 inches). So when i print, a significant part of
the paper remains blank, because of the different margins. Does anyone know
how to programmatically change the printer's default paper? Almost all
properties of the Printersettings Class on this matter are ReadOnly.
Thank u
Panos
- 6
- Visual Basic [VB] >> Saving settingsHi,
is it possible to access the properties of a class or structure in a for
each statement?
I want to iterate through the stirng properties in my class or structure and
then write them away to the config file.
thanks for your help in advance
--
--
TimB
- 7
- MFC >> what am i looking for?Hi. I am working on an MDI application and I am having problems looking for
information. I know what I want, I just dont know exactly what it is
called. When you start an MDI application and build and run it you get a
single document window in the main window. This is right, but I want a bar
docked to the left side of the main window that has a CTreeView control,
much like the folders bar that the Windows explorer has. I started looking
into the CSplitterWnd class which made the left tree like I wanted, but the
right frame looks like I cannot have multiple child windows in it anymore.
The ControlBar looks promising, but I'm not sure how to set it up. Would I
want a DialogBar in it, and if so, would I need a CTreeCtrl instead of
CTreeView? I have done several dialog based mfc applications before, but
SDI/MDI is new to me. Any help is appreciated. Thanx.
jorj
- 8
- Visual Basic [VB] >> Make background of graphics object transparent.I keep getting my string inside a black box with this code.
I would like to make the background transparent. Any help on this will
be appreciated very much.
'**** BEGIN CODE ****
Try
Dim NewFont As New Font(fg.Font.FontFamily, 10, FontStyle.Regular)
Dim g As Graphics
Dim pic As Bitmap = New Bitmap(20, 20,
imaging.PixelFormat.Format24bppRgb)
g = Graphics.FromImage(pic)
g.Clear(Color.Transparent)
g.DrawString("H", NewFont, Brushes.Blue, 0, 0)
Dim st As New System.IO.MemoryStream
pic.Save(st, System.Drawing.Imaging.ImageFormat.Bmp)
Dim img As Image = Image.FromStream(st)
pct.Image = img
Catch exc As Exception
Stop
End Try
'**** END CODE ****
Kalvin
- 9
- MFC >> NetUserSetInfo() HomepathChecked w/VS 6.0 SP6 & .Net & .Net 2003
With NetUserSetInfo() when I set Home Folder Connect, the function works
fine. When I check it from the user manager, the home folder connect letter
and path is also seen. But when the user logs it's does not connect to home
folder. However if I click the edit field and <APPLY> from Windows User
Manager the next logon it connects home folder. Windows 2000 doesn't give any
message but in WServer 2003 prompts a dialog already....
Is it a program mistake or < Windows XP & SP2, Windows 2000, Windows Server
2003 > problem.
ui.usri1053_home_dir_drive = L"U";
ur.usri1006_home_dir = m_homepath;
nStatus = NetUserSetInfo(NULL, m_lpuser, dwLevel, (LPBYTE)&ui, NULL);
NetUserSetInfo(NULL, m_lpuser, dwLevel1, (LPBYTE)&ur, NULL);
- 10
- VB Scripts >> MS Word TAB jumpingI'm making a vbs script that opens a .DOT word document, saves a .DOC
copy, and then modifies the .DOC's content.
The document contains several Text Form Fields. I want the script to
write a string in each of those Fields. How do I enumerate the fields
(jump from one field to the next)?
--
Regards,
Thomas M.
- 11
- Visual Basic [VB] >> Problem parsing dates in .xsdI created an OleDbDataAdapter with the wizard in Visual Studio 2003.
It created a dataset, connectionstring etc. for me to work with. It
also created a .xsd file where one of the columns type is set to date.
My program is being used in many different countries, and many
different local settings. Some time ago a user from Turkey contacted
me saying my program crashed on his system with the following error
code:
System.ArgumentException: The string was not recognized as a valid
DateTime. There is a unknown word starting at index 0.Couldn't store
<Ekim 2006> in Date By Month Column. Expected type is DateTime.
I checked and double checked my code, but couldn't find what was
causing this error. I installed my program on a Turkish friend's
computer and it ran just fine. As a final effort, I changed the
columns type from date to string, handled the parsing of dates myself
in code, and the error was gone.
Could someone please explain why the parsing in my code works, but not
in the .xsd file? And what is the preferred method to use here. I'm
feeling a bit reluctant in changing code that works just fine for 99%
of my users to accomodate just this one.
- 12
- VB Scripts >> Eventlogs Related QuestionMoved here from inetsdk.programming.scripting.vbscript
upon the suggestion of Bob Barrows.
-----
A rather odd set of eventlog questions:
This isn't limited directly to *servers* but is applicable to
them. As I'm certain most of you know, you can create your own
personal "eventlog" and then write your error messages to it.
(The means to do so is clearly outlined on the MS scripting
site.)
Unfortunately, beyond those two steps there is lot that is
left to the imagination not only with regard to the personal
eventlog but also to the normal OS eventlogs. For example:
When one creates an eventlog, how can be certain that it was
successfully created? Assuming that you were successful in
creating the eventlog how can you later check to determine
whether it exists or not? (This question could also apply to
any/all of the usual OS eventlogs as well. [You wouldn't
want to write unless it existed.])
When you try to write a message to/into the/any eventlog, how
can you be certain that the attempt was successful? (Again
this could also be said for the standard OS eventlogs as
well.) [If the attempt failed you might want to write a
failure message into one of the OS eventlogs.]
I suspect that the standard answer will be "by clearing and
then checking the value of *error*" which makes sense, but
of course requires some knowledge of what you're looking
for in advance, which I don't, and which has resulted in
this post.
Does anyone out there have any experience that might be
able to elucidate/illuminate what I might be looking for?
Many thanks in advance.
David
- 13
- Visual Basic [VB] >> Importing Excel into Access with VBI need some code ideas to import Excel into Access using
VB. I need to use VB because the Excel column formats are
not always consistent.
I'm importing a fairly simple spreadsheet.
Any assistance would be greatly appreciated.
- 14
- VB Scripts >> Use AutoItX? maybe AutXtra then?I moderate http://groups.yahoo.com/group/AutoItList/ and I have
created AutXtra.exe http://groups.yahoo.com/group/AutoItList/files/UTIL/AutXtra2.zip
There are 60 odd functions in AutXtra.exe and they can be accessed via
WSH this way...(examples...assume AutXtra.exe is at c:\)
example1:
Set oAutoIt = CreateObject("AutoItX.Control")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objEnv = WshShell.Environment("process")
objEnv("autxtra") = "cdlist"
Set oExec = WshShell.Exec("c:\autxtra.exe *clipboard")
Do While oExec.Status = 0
WScript.Sleep 50
Loop
WScript.Echo oAutoIt.ClipGet()
example2:
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objEnv = WshShell.Environment("process")
objEnv("autxtra") = "cdopen"
objEnv("ax_drive") = "d:"
Set oExec = WshShell.Exec("c:\autxtra.exe *clipboard")
More Commands...
Commands:
-------------
Browse4Folder
CDClose
CDList
CDOpen
ChildClassList
DateAheadAgo
DiskSpace
DownLoad
DisableControl
EnableControl
FileDeleteLine
FileInsertLine
FileReplaceAll
FileReplaceLine
FindInFile (StringInFile)
FindPixel
FocusControl
Get8Dot3
GetComputerName
GetControlStats
GetCursor
GetFileSize
GetFileTime (GetFileDate)
GetLongFileName
GetPixelColor
HideControl
IsAdmin
LowerCase
MoveControl
MyIP
OpenDialog
Play
RemovableList
SaveDialog
ScreenSaverOff
ScreenSaverOn
SendToControl
SendToControlByClass
SetComputerName
ShortCut
ShowControl
StringAnsi2Oem
StringOem2Ansi
StringReplaceAll
StringReverse
TitleCase
UpdateEnv
UpperCase
WallPaper
WinBack
WinGetAllText (WinGetText)
WinGetStats
WinGetTextByClass
WinGetTitle
WinGetVisibleText
WinListAll
WinListVisible
WinNoTopMost
WinSetText
WinSetTextByClass
WinTopMost
--------------
- 15
|
| Author |
Message |
angel_2002_123

|
Posted: Wed Jul 14 22:59:02 CDT 2004 |
Top |
Visual Basic >> Rename files (remove last few random numbers)
Hey everyone I've got a small problem with one of my codes that I can't
figure out how to get around. When I save files from my program it
outputs a name like ******_***_##.ps My problem is the ## is a counter
number generated by the program when it saves the file. What I?m trying
to do is remove this number and its preceding underscore. Below is the
code that I?m currently using. At the present time the code works
great, however, the counter number will soon reach 100, which is 3
digits. Right now the program counts back from the end and is set for 2
digits. I need the program to take this random number off the end
regardless of whether the counter is at 1 or 9999, which is the range of
the counter. The file names vary in length so I cannot count from the
front side of the filename either. The code needs to simply remove
everything from the second underscore on and then put the .ps back on
the end. If you could help me with this I would really appreciate it.
Thanks for your time.
Private Sub Command1_Click()
Dim MyName As String
Dim Temp As String
Dim MyDir As String
MyDir = "c:\temp"
NewDir = "c:\temp2"
Temp = Dir$(MyDir & "*.ps")
Do While Temp <> ""
MyName = Left$(Temp, Len(Temp) - 6)
Name MyDir & Temp As NewDir & MyName & Right$(Temp, 3)
Temp = Dir$()
Loop
msg = "It's done"
MsgBox (msg)
Unload Form1
End Sub
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Visual Studio65
|
| |
|
| |
 |
JayVinton

|
Posted: Wed Jul 14 22:59:02 CDT 2004 |
Top |
Visual Basic >> Rename files (remove last few random numbers)
> outputs a name like ******_***_##.ps My problem is the ## is a counter
> The code needs to simply remove
> everything from the second underscore on and then put the .ps back on
Hi Brian,
Crude but functional. You'll need to add error handling to deal with malformed filenames.
Function FixFileName(strFileName As String) As String
Dim lngEndFirstPart As Long
Dim lngStartLastPart As Long
Dim i As Long
lngStartLastPart = InStr(1, strFileName, ".")
For i = lngStartLastPart To 0 Step -1
If (Mid$(strFileName, i, 1) = "_") Then
lngEndFirstPart = i - 1
Exit For
End If
Next
FixFileName = Mid$(strFileName, 1, lngEndFirstPart) & _
Mid$(strFileName, lngStartLastPart)
End Function
Jay
|
| |
|
| |
 |
| |
 |
Index ‹ Visual Studio ‹ Visual Basic |
- Next
- 1
- MFC >> Path selection dialogHi There,
Just wondering if there is a ready made standard path selector dialog box
just like there is one for file selection.
Thanks
Ashish
- 2
- Visual Basic [VB] >> Mobile Selection List and DatabindingI have the following code:
Dim dv As New DataView(ds.Tables(1), "AnswerSetID = " & drQue _
("AnswerSetID"), "AnswerID",
DataViewRowState.OriginalRows)
sel.DataTextField = "AnswerText"
sel.DataValueField = "AnswerID"
sel.DataSource = dv
When this code renders the html. The DataValueField is ignored. Instead it
populates the value for the options with 0,1,2... and so on.
What am i missing to get the data value to be the contents of the
DataValueField?
- 3
- VB Scripts >> Printer poolingThis might be the wrong group but several of the printer commands from the
nt resource kit.
My question is I have a HP USB printer. For a specific application(legacy)
the only way to get working with the USB connecton is manually checking LPT1
port and Enabling printer pooling.
When I install the printer it will default to a USB port which is fine.
I need to be able to do the command with a script or some for of
command-line.
1. First how do I enable the LP1: port and still keeping the USB port also
checked.
2. Second how do I check the "enable printer pooling"
- 4
- 5
- Visual Basic >> design questionI would appreciate it if someone could give some design tips for the
following:
Goal: Automatic Purchase Order Receiving for material that is recieved in as
lots.
Background: We purchase material as eaches and store them as mm. For each
'billet' of raw material we assign a lot number. Lot # = Julian Date +
Sequenctial Number. ie 3188-01
Example:
PO with 1 line item for 10 billets of material. The billets are 30 mm
length. Therefore we expect to receive a total of 300 mm (10 ea * 300 mm/ea)
So they currently have to be received in 1 at a time (in our current system)
to assign the lot numbers. Each one received get written to the material
transaction table.
ie
rec 1 billet ea, assign lot 3188-01 in location x
System now shows in stock that 30 mm are received at location X with LOT
3188-01
rec 2 billet ea, assign lot 3188-02 in location x
System now shows in stock that 30 mm are received at location X with LOT
3188-02
.
.
.etc
.
.
rec 10 billet ea, assign lot 3188-10 in location x
System now shows in stock that 30 mm are received at location X with LOT
3188-10
I envision VB form with PO header and sub form showing the PO details.
What i dont understand how to construct or what the best control to use is
for the receiving.
I would like to select the PO detail line and then below the PO line detail
subform show:
Each EXPECTED individual line item. ie if there are 10 expected then show:
check box 1 (unchecked) TextBoxPart 1 (Line Item from PO Line) textboxQty
(1) textboxLocation(Default Location of Part) textboxLOT (3188-01)
check box 2 (unchecked) TextBoxPart 2 (Line Item from PO Line) textboxQty
(1) textboxLocation(Default Location of Part) textboxLOT (3188-02)
.
.
.etc for how many are expected.
check box 10 (unchecked) TextBoxPart 10 (Line Item from PO Line) textboxQty
(1) textboxLocation(Default Location of Part) textboxLOT (3188-10)
Then the user can just check the items he wants to recieve in and click a
save button to complete transaction.
There should be an option to Select all.
Problems
1) How do i write a routine to 'spit out' what is described above? Is there
a better way to create/approach this?
2) What happens when I expect to receive 100? Form will get pretty messy.
3) How do I increment each lot?
Thanks in advance for any help!!
- 6
- VB Scripts >> Change Value Data in ScriptI need help with a script for about 3000+ PCs, the value I am trying to
change is in regedit. But will be different for each workstation it
touches. The value I am trying to change is that of network printers
which is going to be different for it PC.
The string Im editing is
"PNAME" = "\\server\printer,0"
To
"PNAME" ="\\server\printer,1"
So basically all I need to do is switch the 0 to a 1 on the printer
options. I have scripts to change the whole thing but none to change
if the printer is going to be different everytime.
Any Suggestions would be helpful?
- 7
- Visual Basic [VB] >> Threading QuestionHi,
I have the following code:
Imports System.Threading
Module Module1
Sub Main()
Dim mydel As New WaitCallback(AddressOf Showmytext)
ThreadPool.QueueUserWorkItem(mydel)
ThreadPool.QueueUserWorkItem(mydel)
ThreadPool.QueueUserWorkItem(mydel)
Console.Read()
End Sub
Sub Showmytext(ByVal state As Object)
Dim mystr As String = CType(state, String)
Console.Write(Thread.CurrentThread.ManagedThreadId)
Dim i As Integer
Dim j As Long
For i = 1 To 10000
j = 0
j = 10000 * 123456
Next
Thread.Sleep(1000)
Console.Write(j)
End Sub
End Module
All my code runs in the SAME thread and runs... synchronously meaning
it ways for the first for i-----sleeps then writes the result on the
console , moves to the next.... etc.
Please somebody explain why.
Thanks,
Carly
- 8
- Visual Basic [VB] >> Causing a onclick event on a <div> in a table through codeI have an example I have been playing with.
The page displays with a vertical menu (like an outlook menu) which is
built from a table. When the page loads the menu is collapsed. If you
click on on of the menu bars that menu slide open.
There is a separate java script file.
When the mouse goes over one of the menu bars it causes a init
function in the script file to run. If you click on the menu it runs
another function.
I want to have one of the menus expanded when the page loads but I
cannot figure out how to call the click event of the <div> tag without
actually clicking on it.
Is this possible?
Thanks for helping a beginner.
Ty
- 9
- Visual Basic [VB] >> Trying to create a colour reference formI'm trying to create many squares on a form and for every new square, change
the background colour to the next colour. I'm trying to create a colour
palette showing all available colours and their colour name.
My problem is that I can not figger out how to create a new panel at
specific intervals across and down the form. Here's the code I have so far:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim xNum As Byte = 4
Dim yNum As Byte = 2
Dim xLoc As Integer = 10
Dim yLoc As Integer = 10
Dim Spacer As Integer = 10
Dim ColourIndex As Object
Dim PanelHeight As Integer = 50
For y As Byte = 1 To yNum
For x As Byte = 1 To xNum
Dim NewPanelObj As New Panel
With NewPanelObj
.Left = xLoc
.Top = yLoc
.BackColor = CType(ColourIndex, Color)
xLoc += .Width + Spacer
End With
Next
yLoc += PanelHeight + Spacer
Next
End Sub
Can someone help me?
--
|
+-- Thief_
|
- 10
- Visual Studio C++ >> Obtain PID'sI would like to know how to obtain a processe's owner from its pid
The sequence of
OpenProcess
OpenProcessToken
GetTokenInformation
LookupAccountSid
does not work on system processes.
This has been documented in MSDN as being casued by lack of
SE_DEBUG_NAME privelege. The KB article Q131065
describes how to enable this privelege in our process so that
OpenProcess does not fail on system processes
The said method works on all processes except system(pid 8) process
and CRSS process.
1)Why does this not work on these processes ?
2)Are there any other rights that have to be assigned to get this to work ?
3)Is there any other method that doesnt require these rights
to obtain the process owner name ?
Iam targeting NT 4.0 sp6 and above (2000 XP etc)
- 11
- MFC >> Precompiled headers and directories/folders in filesystem...i basically understand what pchs are, but i dont know exactly how
their includition interact with the filesystem, and therefore have ...
switch (MyProblems) {
case P1:
"Unexpected end of file while looking for precompiled header
directive..."
break;
case P2:
"d:\microsoft visual studio\vc98\include\crtdbg.h(536):
error C2833: 'operator DEBUG_NEW' is not a recognized
operator or type..."
(recompiling at once helps)
break;
case P3:
"file not found: stdafx.h"
break;
}
_______________________________________________
so, lets say you have (x = .h & .cpp):
StdAfx.x
class0.x
/dir/class1.x
/dir/class2.x
/dir/dir/class3.x
what are the correct settings for the precompiled headers and how do i
include the
StdAfx.h in the files?
- 12
- 13
- 14
- Visual Basic [VB] >> Problem in developing newsreader in vb.netHello,
I am developing a Newsreader in vb.net and i am
getting a problem in posting article to newserver
for a particular set of newsgroups. i developin g
this newsreader using nntp commands.I need
vb.net code for posting a article . I getting a
problem in defining a article format.
Kindly , Send me code for posting article in vb.net
using nntp command "post".
with regards,
balu.
- 15
- Visual Studio C++ >> why Visual Studio can not optimize the initialization code?Hello everyone,
Why Visual Studio compiler can not optimize in this case? I think this case
is almost the same as sample 1, why compiler can optimize sample 1 but can
not optimze sample 2?
(sample 2, http://msdn2.microsoft.com/en-us/library/ms364057(vs.80).aspx)
[Code]
#include <stdio.h>
class A {
public:
A() {printf ("A: I am in constructor\n");i = 1;}
~A() { printf ("A: I am in destructor\n"); i = 0;}
A(const A& a) {printf ("A: I am in copy constructor\n"); i = a.i;}
int i, x, w;
};
class B {
public:
A a;
B() { printf ("B: I am in constructor\n");}
~B() { printf ("B: I am in destructor\n");}
B(const B& b) { printf ("B: I am in copy constructor\n");}
};
A MyMethod()
{
B* b = new B();
A a = b->a;
delete b;
return (a);
}
int main()
{
A a;
a = MyMethod();
}
[/Code]
thanks in advance,
George
|
|
|