|
I'm writing my first VB app. Please no cheering. In VC++ if I had a sting that I wanted to have hex values in it as well as regular letter I could do something like this
CString myData;
myData.Format("these are my hex values \x06 \x4c");
How can I do this is VB? Is there a format function in VB?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
In Visual Basic you will have to do the following.
Let say you have an integer
Dim myInt As Integer = 715
Dim myStr As String
myStr = "0x" & Format(myInt, "x4")
myStr will have the value 0x02cb. If you replace x4 above with X4 then myStr will have the value 0x02CB. The 4 in X4 is a field width, it will pad zeros to fill the field.
Another way to do the same thing
myStr = "0x" & HexVal.ToString("X4")
|
|
|
|
|
Can anyone convert this from C# to VB.net:
object [] arrReturn = null;
string SP_NAME = "GetIDProc";
string RetID;
SqlParameter[] parameters = { SqlAccessor.SqlParameterBuilder("@RetOrderID", SqlDbType.VarChar, 10, ParameterDirection.Output),
};
int iRow = SqlAccessor.ExecuteNonQuery(connectionString,
SqlAccessor.SqlCommandBuilder(new SqlCommand(SP_NAME), parameters),
CommandType.StoredProcedure, out arrReturn);
RetID = (string) (arrReturn[0].Equals(System.DBNull.Value) ? 0 : arrReturn[0]);
if (iRow > 0)
{
string myFormat;
DateTime d = new DateTime();
OrderNum.Text = d.Year.ToString() + "/" + RetID;
}
else
{
OrderNum.Text = "Cannot Get Details";
}
|
|
|
|
|
is this for any homework ?
don't you really understand anything in the code you provide ??
well, as i am in a good day, here is you code, but try to use your brains a bit more next time :
Dim arrReturn() As Object
Dim SP_NAME As String = "GetIDProc"
Dim RetID As String
Dim Parameters As SqlParameters
Parameters = New SqlParameters { _
SqlAccessor.SqlParameterBuilder("@RetOrderID", _
SqlDbType.VarChar, _
10, _
ParameterDirection.Output) _
}
Dim iRow As Integer = SqlAccessor.ExecuteNonQuery(connectionString, _
SqlAccessor.SqlCommandBuilder(New SqlCommand(SP_NAME), _
parameters), _
CommandType.StoredProcedure, _
arrReturn)
RetID = IIf(arrReturn(0).Equals(System.DbNull.Value), 0, arrReturn(0)).ToString()
If iRow > 0 Then
Dim myFormat As String
Dim d As DateTime = New DateTime()
orderNum.Text = d.Year.ToString() & "/" & RetID
Else
orderNum.text = "Cannot Get Details"
End If
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I am getting errors with the following 2 lines:
Dim iRow As Integer = SqlAccessor.ExecuteNonQuery(connectionString, _ SqlAccessor.SqlCommandBuilder(New SqlCommand(SP_NAME), _ parameters), _ CommandType.StoredProcedure, _ arrReturn)RetID = IIf(arrReturn(0).Equals(System.DbNull.Value), 0, arrReturn(0)).ToString()
The errors are:
'SqlParameterBuilder' is not a member of 'System.Data.SqlClient.SqlCommand'.
'Public Overridable NotOverridable Function ExecuteNonQuery() As Integer' has no parameters and its return type cannot be indexed.
'SqlCommandBuilder' is not a member of 'System.Data.SqlClient.SqlCommand'.
|
|
|
|
|
|
The converter you mentioned does not come close at all to converting the C# code posted:
1. Left in the ternary ('?') operator.
2. Left in the 'out' keyword.
3. Left in '+' for string concatenation, which is very poor style (and will generate errors when both operand are not strings).
David Anton
Tangible Software Solutions
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# Converter and the Instant VB C# to VB.NET Converter
|
|
|
|
|
No, it's not perfect but sometimes saves you effort. Also, it seems to work best when you try small sections at a time. However, I've only used it once or twice, when I was working in a contract where they used VB .NET.
Kevin
|
|
|
|
|
Our Instant VB C# to VB.NET converter (www.instantvb.com) produces the following:
Private Sub test()
Dim arrReturn As Object() = Nothing
Dim SP_NAME As String = "GetIDProc"
Dim RetID As String
Dim parameters As SqlParameter() = { SqlAccessor.SqlParameterBuilder("@RetOrderID", SqlDbType.VarChar, 10, ParameterDirection.Output)}
Dim iRow As Integer = SqlAccessor.ExecuteNonQuery(connectionString, SqlAccessor.SqlCommandBuilder(New SqlCommand(SP_NAME), parameters), CommandType.StoredProcedure, arrReturn)
RetID = CStr(IIf(arrReturn(0).Equals(System.DBNull.Value), 0, arrReturn(0)))
If iRow > 0 Then
Dim myFormat As String
Dim d As DateTime = New DateTime()
OrderNum.Text = d.Year.ToString() & "/" & RetID
Else
OrderNum.Text = "Cannot Get Details"
End If
End Sub
David Anton
Tangible Software Solutions
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# Converter and the Instant VB C# to VB.NET Converter
|
|
|
|
|
David,
Thanks for the reply. Somone gave me this code but they didn't tell me what they declared SqlAccessor as. Would you have any ideas what SqlAcessor should be declared as from looking at the code??
Thanks.
|
|
|
|
|
Sorry - there's a number of different classes with a "ExecuteNonQuery" method. And there are no classes that sound close enough to SqlAccessor, so I couldn't say what it's declared as.
David Anton
Tangible Software Solutions
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# Converter and the Instant VB C# to VB.NET Converter
|
|
|
|
|
HI to all
Please tell me how to create the setup file for the project which have database (SQL SERVER 2000) in it?
Please exaplain me the whole procedure of creating the setup file so that i can install this project on any other machine.
Thanx for help in advance.
BYE from ARFAN QADIR
|
|
|
|
|
Deploying apps is pretty simple and you should be able to get detailed information from any VB.net book. However, to get you started, right click on your solution, select Add->New Project then click on Setup and Deployment Projects and select Setup Wizard. In the options select Setup for windows app and <primary output<="" b=""> from your project.
The setup automatically detects all dependencies needed for your app.
Now, if your project has a database then you should be able to include any additional files in your setup project.
|
|
|
|
|
Hi.
I have a VB.NET program that is creating Word documents based on an existing template file by filling in data retrieved from a database. Some of the content in the Word document is maintained in custom properties, however, although it is very easy to manage these from with a Word macro, I am having difficulty getting hold of the CustomDocumentProperties collection from within VB.NET. Originally, I tried having a variable of type Word.CustomProperty which I would use, in conjunction with the CustomDocumentProperties collection, but had absolutely no joy. Am I being stupid and missing something very obvious.
The problem seems to be that for some reason, CustomDocumentProperties is of type System.__COMObject and does not have any discernable methods or properties. For now, I have created a single line word macro (as part of the original template) that simply sets a custom property to the value you desire, but this is far from ideal, and really goes against the grain for me!! Unfortunately, this is not a solution that can be entirely coded in Word as it is essentially a very small part of a bigger solution (the word doc is just something that is produced at the same time as other things)
Does anyone have any experience with CustomDocumentProperties from VB.NET when talking to Office 2003. I prefer to use Option Strict On, but if it is necessary to turn it off, I will!
A code snippet from .NET that I am using (simplyfied) is shown below. Any help with this would be greatly appreciated
Imports Word = Microsoft.Office.Interop.Word
..
..
..
Dim oWord As Word.ApplicationClass
Dim docCurrent As Word.Document
'
' Start MS Word and open the document.
'
oWord = CType(CreateObject("Word.Application"), Word.ApplicationClass)
docCurrent = oWord.Documents.Open(FileName:="C:\MyOriginalDoc.doc", ReadOnly:=True)
'
' Since it seems impossible to get to the CustomDocumentProperties collection with the Word
' object Model through VB.NET, we run a little macro that is embedded in the template to
' populate the custom properties. Not nice, but apparently necessary - although I won't be
' defeated, so whatch this space!
'
oWord.Run("SetDocProperty", "PhaseDescription", strPhaseDesc)
'
' And now we update the fields
'
docCurrent.Fields.Update()
oWord.Options.PrintFieldCodes = False
docCurrent.PrintOut()
docCurrent.SaveAs("c:\MyNewDocument.doc")
'Quit Word.
oWord.Quit()
Marshal.ReleaseComObject(oWord)
oWord = Nothing
|
|
|
|
|
I have a command in my project like:
wordDoc.Content.Find.Execute(FindText:="#TEST#", ReplaceWith:="ABC" & chr(13) & "DEF", Replace:=Word.WdReplace.wdReplaceAll)
This code will replace #TEST# with this one
ABC
DEF
but , once i have this Word document... the content became ABCDEF , where there is no more "carriage return" in between..
anyone can help me??
|
|
|
|
|
="ABC" & chr(13) & chr(10) & "DEF"
|
|
|
|
|
that coding also can't solve the problem..
|
|
|
|
|
I have solved the problem. the template file i opened is in .rft format. i try to change the format to .doc. then the problem solved..
|
|
|
|
|
hai..i have an access database with 38 tables..
the problem is with the data reports..
its getting delay generating reports and sometimes its displaying the report with some fields missing from the database..and the report is not at all refeshing...
its displaying the old records only...
how can i solve this problem...everyhtis is perfect with connection..
how to avoid the delay..
plz help me
thanks in advance
|
|
|
|
|
hello VB programmers,
i would like to give a window page as an input to printer. please help me to clarify my doubt. Otherwise give me a idea of "how to print the content of a page in printer?"(in VB6.0). Mail me as soon as possible.
lovingly urs,
mahee...
|
|
|
|
|
|
I am unable to implement drill down in vb.net. pls help me, if possible send the code.
|
|
|
|
|
What are you trying to drill down into ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
Has anyone tried trapping the sort event of a datagrid in VB.NET?
We can set the AllowSorting property to true.Then when the column header is clicked,the rows get automatically sorted in ascending and descending order.
However this event isnot listed in the events dropdown list.
I need to trap this event for:
Im populating the grid using a temporary datatable.When the grid is sorting records, I need the temporary table also to be sorted in ascending or descending order.
Any help on this would be gr8.
|
|
|
|
|
implementing this is going to more of a headache than it's worth. when you click the column headers of a datagrid, the underlying datasource's (so long as you are binding to a datagrid, datatable, or dataview) dataview property is going to be re-sorted as well. just use that to access your data.
or, another option is to use the bindingmanagerbase and currency manager to access the particular data you want.
hope this helps.
-jim
|
|
|
|