|
Nope, don't have that code in my programs.
"The things that will destroy us are: politics without principle; pleasure without conscience; wealth without work; knowledge without character; business without morality; science without humanity; and worship without sacrifice."
-Mahatma Gandhi (1869-1948)
|
|
|
|
|
5 from string " asdcxxv (5)". Thanks.
<italic>Work hard, Work effectively.
|
|
|
|
|
A regular expression, like "\((\d*)\)".
This will match any digits within brackets, and put them into match group 1.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I mean, I want to get the number within brackets. I couldn't find any VB function to get the position of "(" character in the string. I'm looking something like indexOf, Find, or something like that. I'm using VB6.
<italic>Work hard, Work effectively.
|
|
|
|
|
You don't have regex in VB6 ? I thought you did. I'm sorry, I don't use any variety of VB, I have certainly never installed VB6. I hope someone else can help you.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Read MSDN on use of InStr function. It can be used to search strings for any character.
Robert
|
|
|
|
|
Hi Yulianto,
try this thing,
Dim Str, StrValue, StrTemp As String
Dim PosStart, PosEnd As Integer
Str = "asdcxxv (5)"
PosStart = InStr(Str, "(")
StrTemp = Mid(Str, PosStart + 1)
PosEnd = InStrRev(StrTemp, ")")
StrValue = Mid(StrTemp, 1, PosEnd - 1)
MsgBox StrValue
hope this helped you
Het Waghela
Be Humble in Victory and Strong in Defeat.
Het Waghela, Blog|Het Waghela DotNet Questions Link|More Links
|
|
|
|
|
I am trying to create a customeizable unix style program launcher
(for those of you who dont know unix, it is a lot of 3d cubes sitting in clusters)
using a MDI container to launch the programs in.
is it possible to launch a external program (MSWord for instance) inside a MDI container as a child? if so, how??
Thanks a lot.
|
|
|
|
|
What are the limitations of custom controls in VB.NET?
Is my imagination the limit?
|
|
|
|
|
nick.ueda wrote:
What are the limitations of custom controls in VB.NET?
Is my imagination the limit?
No, your ability to code them in such a way that they are responsive and useful is the limit.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
but I can create one from scratch correct?
hypothetically I can create a custom control
that looks like nothing anyone has ever seen?
I guess I am trying to ask if I am limited to
only inheriting controls that already exist
within the .Net Framework. I can create base
controls myself and build on them right?
|
|
|
|
|
You can inherit from a base Control class that does nothing, and then you'll be responsible for all painting and event handling, meaning you can create a control that does whatever you like. However, unless you have a strong need to do otherwise, you should base your controls on existing ones ( for example, a text box that validates input should just look like a normal text box at first glance ), so that your users are not confused.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I understand...yeah I wasn't looking to stray too
far from standards but I have an idea in my mind
for a control that I think would work really well
for an application that I am working on. I need
to try it out, but I wanted to verify that it is
possible to create anything before I waste my time.
|
|
|
|
|
No worries. Good luck with it. I suggest checking articles here on CP first, it's possible someone has already written the control you have in mind, and presented it as an article. At the least, you'll get lots of info on how best to write custom controls.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
There is an excellent library here on CodeProject contributed by Omid Shahabi called CadLib for creating viewing and modifying dxf(Drawing Interchange Format) files
I am attempting to use this C++ library in VB.Net and have started to write the declare functions to do so - example follows
____________________________________________________________________________
Private Declare Function drwCreate Lib "CADIO" () As Long
Private Declare Function drwInitView Lib "CADIO" (ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal Nheight As Integer) As Boolean
Private Declare Function drwLoadDataFromFile Lib "CADIO" (ByVal Handle As Long, ByVal BlockHandle As Long, ByVal Res0 As Integer, ByVal Filename As String, ByVal ProgHandle As Long) As Boolean
Private Declare Function drwSaveDataToFile Lib "CADIO" (ByVal Handle As Long, ByVal Res0 As Integer, ByVal Filename As String, ByVal ProgHandle As Long) As Boolean
Private Declare Function drwPaint Lib "CADIO" (ByVal drwhandle As Long) As Boolean
____________________________________________________________________________
The dwfCreate worked well, returning a (long integer) handle
But I am having trouble figuring out how to pass null values where required (i.e in drwLoadDataFromFile) and how to handle the C++ "progress window handle")
Do any experts out there have any suggestions of how to use this library in VB.net to display a dxf file (as in the C++ test program)
Many Thanks
|
|
|
|
|
If you create a form, you can get the window handle from it, it's a property.
Isn't Nothing the same as null ? If not, then just pass 0, a pointer with a value of 0 is null in C++.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks Christian,
I will try passing 0 as an integer value where I need a null sent to the C++ dll.
For the handle to the "progress form" I take it that i would create a form in VB.Net and pass it's handle to the file open as shown.
Regards
|
|
|
|
|
Reanalyse wrote:
For the handle to the "progress form" I take it that i would create a form in VB.Net and pass it's handle to the file open as shown.
I'd assume they need the form to have a progress bar on it with a specific ID, so that it can use it to update it's progress. I'd also hope you could pass null ( IntPtr.Null probably exists for this purpose ), and not have a progress dialog at all.
It's IntPtr.Zero ( I just checked ), so I'd try passing that rather than a straight 0, where Null is concerned.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks Christian
I have got a long way down the track thanks to your help
I have got this far
Am I passing the correct way to a VC++ DLL from VB.NET ?
------------------------------------------------------------------------------
Structure PVIEW
'// View Structure **********************************************
'typedef struct tag_VIEW
'{
'BOOL Viewable; // TRUE = Drawing can be viewed
'int WindowLeft; // Drawing Window Boundary Properties (In Pixels)
'int WindowTop; // Drawing Window Boundary Properties (In Pixels)
'int WindowRight; // Drawing Window Boundary Properties (In Pixels)
'int WindowBottom; // Drawing Window Boundary Properties (In Pixels)
'double ViewLeft; // Drawing View Properties (In Units)
'double ViewBottom; // Drawing View Properties (In Units)
'double ViewRight; // Drawing View Properties (In Units)
'double ViewTop; // Drawing View Properties (In Units)
'double PPU; // Pixels Per Unit
'double ZoomLevel; // Zoom Level
'} VIEW, *PVIEW;
Public Viewable As Boolean
Public WindowLeft As Integer
Public WindowTop As Integer
Public WindowRight As Integer
Public WindowBottom As Integer
Public ViewLeft As Double
Public ViewBottom As Double
Public ViewRight As Double
Public ViewTop As Double
Public PPU As Double
Public ZoomLevel As Double
End Structure
Public Class Form1
Inherits System.Windows.Forms.Form
Public Declare Function drwCreate Lib "CADIO" () As Long
'Exported Function drwCreate
'BOOL Create( );
Private Declare Function drwLoadDataFromFile Lib "CADIO" (ByVal Handle As Long, ByVal Handle1 As Long, ByVal Res0 As Integer, ByVal Filename As String, ByVal Handle2 As Long) As Boolean
'Exported Function drwLoadDataFromFile
'BOOL (*drwLoadDataFromFile)( HDRAWING hDrawing, OBJHANDLE BlockObjhandle, DWORD Reserved, LPCTSTR strFileName, HWND hWndProgress );
Public Declare Function drwInitView Lib "CADIO" (ByVal Handle As Long, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal Nheight As Integer) As Boolean
'Exported Function form DLL =drwInitView
'Public BOOL InitView( int x, int y, int nWidth, int nHeight );
Private Declare Function drwPaint Lib "CADIO" (ByVal drwhandle As Long) As Boolean
Private Declare Function dxfSetCurrentColor Lib "CADIO" (ByVal drwhandle As Long, ByVal Color As Integer) As Boolean
Private Declare Function drwGetViewProperties Lib "CADIO" (ByVal drwhandle As Long, ByVal Thisview As PVIEW) As Boolean
Private Declare Function drwAddBlock Lib "CADIO" (ByVal drwhandle As Long) As Boolean
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Button1 As System.Windows.Forms.Button
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(128, 72)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 0
Me.Button1.Text = "Button1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim drwhandle1 As Long
Dim Blockhandle As Long
Dim RetVal As Boolean
Dim CurrentView As PVIEW
drwhandle1 = drwCreate()
RetVal = drwInitView(drwhandle1, 1, 1, 300, 300) 'returns true
RetVal = dxfSetCurrentColor(drwhandle1, 1) 'returns true
RetVal = drwPaint(drwhandle1) 'returns true
RetVal = drwAddBlock(drwhandle1) 'returns true
'Here is where trouble occurs
RetVal = drwGetViewProperties(drwhandle1, CurrentView) 'Does not work
RetVal = drwLoadDataFromFile(drwhandle1, Nothing, 0, "H:\test.dxf", Nothing) 'does not work
____________________________________________________________________________
The last two calls did not work at all
Regards
|
|
|
|
|
A BOOL is in fact a typedef for an int, pass 0 for false, 1 for true. It's used in APIs that are to be called from C, as C does not have a boolean type.
Are you declaring your handles as IntPtr ( can you access that type in VB.NET ) ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Changed both of those (you can use IntPtr in VB.Net but ")" as boolean came as a surprise ),the code previously still will not work with the changes.
Thanks
|
|
|
|
|
Reanalyse wrote:
boolean came as a surprise
Yeah, it's definately a trap.
Reanalyse wrote:
the code previously still will not work with the changes.
To be honest, anything else I suggest will just be a stab in the dark. If it were me, I'd be trying to use the dll in C++, then if I got that to work successfully, I'd be trying to move it to VB.NET. If it was usable in C++ and hard to use in VB.NET, I'd wrap it in a C++ COM project, and call that from VB.NET.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
i have written an App config file for my SQL server application containing the connection string. Im not sure if i have written the right code to read the connectionstring because when i run my app it says "ConnectionString is not initialized". Does anyone have any words of wisdom for my situation?????? If you do i will consider you the smartest person ever!
|
|
|
|
|
Hi Joey,
I just went through this myself.
Be sure you do this....
1. Be sure you have the ADODB component in your project
From VB menu.....Project - Components - Microsoft ADO Data Contro 6.0 (OLEDB)
2. Be sure you put the ADODB component on your form.
Example: Adodc1
3. Establish the database connection.....mine was to a SQL Server via ip
I put this in General-Declarations
Dim db As New ADODB.Connection
Const dbConnectString = "Provider=sqloledb;" & _
"Network Library=DBMSSOCN;" & _
"Data Source=xxx.xx.xx.xx,1433;" & _
"Initial Catalog=my_db_name;" & _
"User ID=my_user_ID;" & _
"Password=my_password"
4 Make the database connection in your code
db.Open dbConnectString
curID="1"
mySQL = "SELECT * FROM customer WHERE ID=" & curID& ";"
Set rs = db.Execute(mySQL _queID)
CompanyName = rs("CompanyName")
rs.Close
db.Close
set rs=nothing
set db=nothing
HTH
---- Mike
|
|
|
|
|