|
You can't go through a string like that. You need to "extract" each character by using either substring or mid.
For i = 0 to s.length -1
c = c Xor s.substring(i,1)
Next
try that?
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
<br />
Dim s As String = "this is a string"<br />
Dim n As Integer = 0<br />
Dim c As Char<br />
<br />
For Each c In s<br />
<br />
n = n Xor Microsoft.VisualBasic.Val(c)<br />
<br />
Next<br />
VB is as nasty as I remember it, but it can indeed step through the characters of a string.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
ok... i stand corrected. i forgot about the "char".
just curious...if you can't stand vb...why answer questions in the vb forum?
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
nlarson11 wrote: just curious...if you can't stand vb...why answer questions in the vb forum?
Because it's all .NET at the end of the day. When it was C++ and VB6, I'd never consider it, b/c I had no idea. Nowadays, I can answer most questions, even if I struggle to get the syntax right.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
ah. your obviously knowledgable...just seem miserable
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
Hi All,
I am writing an Email Program ...But for some reason i am getting this Error
"The remote certificate is invalid according to the validation procedure.,"
Here is my Code
Dim smtpServer As New SmtpClient
Dim mailMessage As New MailMessage
smtpServer.Credentials = New Net.NetworkCredential(txt_FromEmail.Text, txt_password.Text)
smtpServer.Port = txt_Port.Text
smtpServer.Host = txt_SmtpSvr.Text
smtpServer.EnableSsl = True
mailMessage.From = New MailAddress(txt_FromEmail.Text)
mailMessage.To.Add(txt_MailTo.Text)
mailMessage.Subject = txt_Subject.Text
mailMessage.Body = txt_msgBody.Text
smtpServer.Send(mailMessage)
MsgBox("mail Send!!", MsgBoxStyle.Information)
Thnks all ..Will Realy Appreciate any help
|
|
|
|
|
See this[^] MSDN discussion.
|
|
|
|
|
I am having tha same problem working in C#.
I can use 2 of my personal email accounts to send mail but when I try to send email with a company email account I get the the same "The remote certificate is invalid according to the validation procedure.". floowed the link that N a v a n e e t h suggested and I spent the time figuring out how to get the JIT debug log. Maybe the answer is there but I don't recoginze it.
Any words of wisdom would be appreciated!
|
|
|
|
|
Looking at the log file this is where things seem to take a turn for the worse. But I don't understand enough to figure out why?
[Public Key]
Algorithm: RSA
Length: 1024
Key Blob: 30 81 89 02 81 81 00 cb 8a cb fc 94 b8 bd 63 6d 30 b4 45 3f be b8 cc 83 9e 32 3c df eb f3 ba f9 79 4d 7f a5 04 57 cf 36 74 26 f7 3a cb 6d 39 d8 87 e2 70 73 a8 e0 d2 4f e5 8c 27 b3 47 6d a7 ad 7e e2 d5 e6 22 7f 85 d3 4e 2b 66 20 8....
System.Net Information: 0 : [1972] SecureChannel#2389992 - Remote certificate has errors:
System.Net Information: 0 : [1972] SecureChannel#2389992 - Certificate name mismatch.
System.Net Information: 0 : [1972] SecureChannel#2389992 - A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
System.Net Information: 0 : [1972] SecureChannel#2389992 - A required certificate is not within its validity period when verifying against the current system clock or the timestamp in the signed file.
The other thing I have figured out is that in Outlook account settings - More Settings - Outging server we need to check the My outgoing server (SMTP) requires authenticatin and "Use same settings as my incomming mail server"
This would make me think my program should be able to get the authentication info need from the incoming mail server but how??
Once again - any words of wisdom would be apreciated.
|
|
|
|
|
Hello,
I am programming in vb.net (VS2005).
I am trying to sort date column in datagridview but with no success.
When I am clicking on header of the column to sort, I got sorting only by day:
for example:
01/05/2009
02/03/2009
03/08/2008
...
instead of getting:
03/08/2008
02/03/2009
01/05/2009
I tried to parse the column to DateTime but it dosn't help.
I tried in Cell_Parsing event also to Parse but the evnet didn't fire at all.
Can you please give any idea how to do it.
Thank you for help
Shay Noy
|
|
|
|
|
Try setting the DataGridViewColumn.DefaultCellStyle.Format as "d".
Is the datagridview bound?
It's not necessary to be so stupid, either, but people manage it. - Christian Graus
|
|
|
|
|
It doesn't help too.
The datagridview is Unbound.
I had added the columns in design mode through the "Edit Columns" feature of the datagridview.
The sortMode is set to Automatic and as you said the DataGridViewColumn.DefaultCellStyle.Format is set to d.
Thank you
Shay Noy
|
|
|
|
|
You will need to handle the SortCompare event for the datagridview and sort the data there.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Thank you, I will try this.
Shay Noy
|
|
|
|
|
Hi - if you are still searching for an answer, I got one for you.
It involves implementing the icomparer class.
Add this to the your form:
Public Class DataGridViewSortRowsByDateTime
Implements System.Collections.IComparer
Private Direction As Integer = 1
Public Sub New(ByVal so As SortOrder)
If so = SortOrder.Descending Then
Direction = -1
ElseIf so = SortOrder.Ascending Then
Direction = 1
End If
End Sub
Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer _
Implements System.Collections.IComparer.Compare
Dim RowOne As DataGridViewRow = CType(x, DataGridViewRow)
Dim RowTwo As DataGridViewRow = CType(y, DataGridViewRow)
Dim Result As Integer = _
System.DateTime.Compare(RowOne.Cells(0).Value, RowTwo.Cells(0).Value)
Return Result * Direction
End Function
End Class
NOTE: This sorts on column index(0). You can assign your column index to whatever you like by changing the value of x in the statement:
System.DateTime.Compare(RowOne.Cells(x).Value, RowTwo.Cells(x).Value)
Then after loading your data into the datagridview, add this line at the end:
DataGridView1.Sort(New DataGridViewSortRowsByDateTime(SortOrder.Ascending))
for ascending or:
DataGridView1.Sort(New DataGridViewSortRowsByDateTime(SortOrder.Descending))
I hope that helps (it did for me!)
modified on Friday, November 20, 2009 3:50 AM
|
|
|
|
|
Hi all bro:
I tried many times to use the following libraries :
Microsoft.Office.Interop.Excel or:
Microsoft.Office.Tools.Excel to get the Excel.Application by autocomple property of the .Net IDE but i failed.
Be informed that i added the Microsoft.Excel 11 library to my project reference and i downloaded PIA files and runned them but no use
help me please i have to use Excel sheet in importing / exporting my data
ezzat oraby
|
|
|
|
|
You can create a excel file through File.Create method. In order to import and export the data, you can create a OleDB connection to the excel file and then use SQL commands on it.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus
|
|
|
|
|
"You can create a excel file through File.Create method. In order to import and export the data, you can create a OleDB connection to the excel file and then use SQL commands on it."
sorry friend for being late but how could i do i need an example
ezzat oraby
|
|
|
|
|
'i made class in seperate file
Imports System.Threading
Class program
Private Class MessageInfo
Private iteration As Integer
Private message As String
Public Sub New(ByVal iteration As Integer, ByVal message As String)
Me.iteration = iteration
Me.message = message
End Sub
Public ReadOnly Property Iterations() As Integer
Get
Return iteration
End Get
End Property
Public ReadOnly Property Messages() As String
Get
Return message
End Get
End Property
End Class
Public Shared Sub DisplayMessage(ByVal state As Object)
Dim config As MessageInfo = TryCast(state, MessageInfo)
If config Is Nothing Then
Dim count As Integer
For count = 0 To 2 Step count + 1
Console.WriteLine("a thread pool example")
Thread.Sleep(1000)
Next
Else
Dim count As Integer
For count = 0 To config.Iterations - 1 Step -1
Console.WriteLine(config.Messages)
Thread.Sleep(1000)
Next
End If
End Sub
End Class
'and try to use it in sub Main
Imports System.Threading
Module Module1
Sub Main()
ThreadPool.QueueUserWorkItem(MessageInfo.DisplayMessage)
Dim info As New MessageInfo(5, "a thread pool example with arguments")
ThreadPool.QueueUserWorkItem(MessageInfo.DisplayMessage, info)
Console.WriteLine("Main method complete. press enter")
Console.ReadLine()
End Sub
End Module
error
Error 1,2,3 Type 'MessageInfo' is not defined. C:\Documents and Settings\Sokar\My Documents\Visual Studio 2005\Projects\ConsoleApplication16\ConsoleApplication16\Module1.vb 7 25 ConsoleApplication16
Ahmed hassan
|
|
|
|
|
Dont post this a second time. Keep it in your original post thread. Also, this problem has nothing to do with threading.
|
|
|
|
|
i try to convert c# code to vb.net code but i have probelm with execute displayMessage in Main sub .I am trying to covert the code at many websites which provide coverting service but most of it have the same error
can any one concert it to vb.net code
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace ConsoleApplication13
{
class Program
{
private class Massegeinfo
{
private int iterations;
private string massage;
public Massegeinfo (int iterations,string massage)
{
this.iterations=iterations;
this.massage=massage;
}
public int Iterations{get{return iterations;}}
public string Massage{get{return massage;}}
}
public static void displayMessage(object state)
{
Massegeinfo config=state as Massegeinfo ;
if (config==null)
{
for(int count=0;count<3;count++)
{
Console.WriteLine("a thread pool example");
Thread.Sleep(1000);
}
}
else
{
for(int count=0;count < config.Iterations;count++)
{
Console.WriteLine(config.Massage);
Thread.Sleep(1000);
}
}
}
static void Main(string[] args)
{
ThreadPool.QueueUserWorkItem(displayMessage);
Massegeinfo info = new Massegeinfo(5, "A thread pool example with arguments");
ThreadPool.QueueUserWorkItem(displayMessage, info);
Console.WriteLine("Main method complete. press enter");
Console.ReadLine();
}
}
}
Ahmed hassan
|
|
|
|
|
What is the error?
I suspect it is to do with the for-next loop and the indexes used, but without knowing the error you are getting it is difficult to be sure.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
i tried to convert this code i made class in seperate file
Imports System.Threading
Class program
Private Class MessageInfo
Private iteration As Integer
Private message As String
Public Sub New(ByVal iteration As Integer, ByVal message As String)
Me.iteration = iteration
Me.message = message
End Sub
Public ReadOnly Property Iterations() As Integer
Get
Return iteration
End Get
End Property
Public ReadOnly Property Messages() As String
Get
Return message
End Get
End Property
End Class
Public Shared Sub DisplayMessage(ByVal state As Object)
Dim config As MessageInfo = TryCast(state, MessageInfo)
If config Is Nothing Then
Dim count As Integer
For count = 0 To 2 Step count + 1
Console.WriteLine("a thread pool example")
Thread.Sleep(1000)
Next
Else
Dim count As Integer
For count = 0 To config.Iterations - 1 Step -1
Console.WriteLine(config.Messages)
Thread.Sleep(1000)
Next
End If
End Sub
End Class
'and try to use it in sub Main
Imports System.Threading
Module Module1
Sub Main()
ThreadPool.QueueUserWorkItem(MessageInfo.DisplayMessage)
Dim info As New MessageInfo(5, "a thread pool example with arguments")
ThreadPool.QueueUserWorkItem(MessageInfo.DisplayMessage, info)
Console.WriteLine("Main method complete. press enter")
Console.ReadLine()
End Sub
End Module
error
Error 1,2,3 Type 'MessageInfo' is not defined. C:\Documents and Settings\Sokar\My Documents\Visual Studio 2005\Projects\ConsoleApplication16\ConsoleApplication16\Module1.vb 7 25 ConsoleApplication16
Ahmed hassan
|
|
|
|
|
The code won't compile until you supply the library and reference supplying the MessageInfo class. This is not a class that comes in the .NET Framework. You'll have to go back to where you got the code from and see if you can find any information on where this class is comming from.
|
|
|
|
|
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Threading
Namespace ConsoleApplication13
Friend Class Program
Private Class Massegeinfo
'INSTANT VB NOTE: The variable iterations was renamed since Visual Basic does not allow class members with the same name:
Private iterations_Renamed As Integer
'INSTANT VB NOTE: The variable massage was renamed since Visual Basic does not allow class members with the same name:
Private massage_Renamed As String
Public Sub New(ByVal iterations As Integer, ByVal massage As String)
Me.iterations_Renamed=iterations
Me.massage_Renamed=massage
End Sub
Public ReadOnly Property Iterations() As Integer
Get
Return iterations_Renamed
End Get
End Property
Public ReadOnly Property Massage() As String
Get
Return massage_Renamed
End Get
End Property
End Class
Public Shared Sub displayMessage(ByVal state As Object)
Dim config As Massegeinfo=TryCast(state, Massegeinfo)
If config Is Nothing Then
For count As Integer = 0 To 2
Console.WriteLine("a thread pool example")
Thread.Sleep(1000)
Next count
Else
For count As Integer = 0 To config.Iterations - 1
Console.WriteLine(config.Massage)
Thread.Sleep(1000)
Next count
End If
End Sub
Shared Sub Main(ByVal args() As String)
ThreadPool.QueueUserWorkItem(AddressOf displayMessage)
Dim info As New Massegeinfo(5, "A thread pool example with arguments")
ThreadPool.QueueUserWorkItem(AddressOf displayMessage, info)
Console.WriteLine("Main method complete. press enter")
Console.ReadLine()
End Sub
End Class
End Namespace
David Anton
http://www.tangiblesoftwaresolutions.com
Convert VB to C#, C++, or Java
Convert C# to VB, C++, or Java
Convert C++ to C#, VB, or Java
Convert Java to C#, C++, or VB
|
|
|
|