我使用下面的代码减去两个日期
Dim OpenDate, ClosedDate As DateTime
dim Result as String
OpenDate = Convert.ToDateTime(some string contain date and time)
ClosedDate = Convert.ToDateTime(some string contain date and time)
Result = ClosedDate.Subtract(OpenDate).ToString
Run Code Online (Sandbox Code Playgroud)
它的格式正确,结果正常(day.hour:minute:second)
我需要的是什么
如果关闭和开放日期之间的期间包含星期五或星期六从结果中减去
防爆.如果结果9.03:02:10包含2周六和周五,则必须是6.03:02:10,依此类推
如果此关键字引用类的当前实例作为程序类中的实例(Application.Run(new Form1()))
我们可以使用此关键字来访问它的属性
this .Text = "debuggging";
this .Opacity = 54;
this .ShowIcon = true;
this .Size = new Size(100, 100);
Run Code Online (Sandbox Code Playgroud)
为什么不能用Form1.ActiveForm达到它.*(所有房产)
只是出于好奇,但为什么
当像这样编码
Form1.ActiveForm.Text = "debugla";
Form1.ActiveForm.Opacity = 54;
Form1.ActiveForm.ShowIcon = true;
Form1.ActiveForm.Size = new Size(100, 100);
Run Code Online (Sandbox Code Playgroud)
和activeform必须为我们带来当前使用的活动表单
抛出null引用异常为什么?
我有一个方法从我的数据库中检索多个结果,我想将这些结果作为一个对象返回到我的页面,但是目前它只是返回sql命令的最后一个结果.
我的页面上的代码调用方法:
Personen persoon1 = Personen.GetOneItem(int.Parse(TextBox_id.Text));
Run Code Online (Sandbox Code Playgroud)
方法代码:
public static Personen GetAllPersonWithID(int id)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["RestaurantConnection"].Connection
String;
SqlCommand cmd = new SqlCommand("SELECT * FROM Personen where reservering_id=" + id, con);
con.Open();
SqlDataReader rdr = cmd.ExecuteReader();
Personen Item = new Personen();
while (rdr.Read())
{
Item.id = Convert.ToInt32(rdr["id"]);
Item.menu_id = Convert.ToInt32(rdr["menu_id"]);
Item.reservering_id = Convert.ToInt32(rdr["reservering_id"]);
}
con.Close();
return Item;
}
Run Code Online (Sandbox Code Playgroud)
它只返回对象中的最后一个结果.
提前致谢
我正在将一个应用程序转换为VB.Net,我无法弄清楚如何将下面的行转换为VB.Net.此应用程序引用了Sharepoint,因此该对象引用了sharepoint组件.
context.Load(item = listFields.GetItemById(listItemId);
Run Code Online (Sandbox Code Playgroud)
有关如何将此转换为vb.net的任何建议?
我有一串
UNCON1\r\nMCF\r\n10/16/14 21:08:40\r\n4452 LANCASTER DR NE\r\nM32,
E305\r\nMCF201410160019\r\n
Run Code Online (Sandbox Code Playgroud)
我要结果4452 LANCASTER DR NE。它总是在第四行。
我就是这样
private void Test(string msg)
{
for (int i = 0; i < 3; i++)
{
msg = msg.Substring(msg.IndexOf("\\r\\n")).Substring(4);
}
string address = msg.Remove(msg.IndexOf("\\r\\n"));
}
Run Code Online (Sandbox Code Playgroud)
有什么好办法吗,谢谢
当我使用此代码时:
Dim sessionid = "sessionid = " + """" + TextBox2.Text + """"
Dim steamlogin = "steamLogin = " + """" + TextBox3.Text + """"
Dim steamparental = "steamparental = " + """" + """"
Dim sortextera = "sort = " + """" + """"
MsgBox(SettingsDir, sessionid + steamlogin + steamparental + sortextera, True)
Run Code Online (Sandbox Code Playgroud)
Visual Basics出现错误,说它无法将其转换为字符串.有帮助吗?
我需要触发一个API,它需要我传递10个字符串的字符串.说我有一个参数
string foo = "foo";
Run Code Online (Sandbox Code Playgroud)
但要发送到此API,而不是发送"foo",我需要发送"foo ".
.net是否具有字符串功能以使此任务更容易?
任何c#或vb.net代码都是可以接受的.
我有一个程序,可以创建一个从文本文件中命名的给定数量的文件夹.我有以下算法:
private void button2_Click(object sender, EventArgs e)
{
if (path != null && Directory.Exists(path))
{
Random rnd = new Random();
for (int i = 0; i < value; i++)
{
var lines = File.ReadAllLines(path1);
var randomLineNumber = rnd.Next(0, lines.Length);
var line = lines[randomLineNumber];
StringBuilder b = new StringBuilder();
for (int j = 0; j < line.Length; j++)
{
char c = line[j];
if (rnd.Next(2) == 0)
{
c = Char.ToUpper(c);
}
b.Append(c);
if (j % 2 == 1)
{
b.Append(rnd.Next(10)); …Run Code Online (Sandbox Code Playgroud) 如果这是字段中的第一个字符,我需要一种删除逗号的方法.例如,数据将,Monday不是简单地读取Monday 我如何判断逗号是否是字段中的第一个字符,以及是否将其删除?
Dim strOrig = "192/8' 33/5' 76/24' 17/12'"
Run Code Online (Sandbox Code Playgroud)
大家好,我想在"/"之前获得每个数字.输出将是318.关于如何实现它,我能想到的是:
1.通过查找"间距"作为每个段的终点并将它们放入数组中来拆分所有段.例如(0)192/8,(1)33/5,(2)76/24等......
2.通过循环数组,查找斜杠"/"并获取它之前的数字并将其求和直到循环结束.例如(0)192,(1)33,(2)76等......
我想知道我的方法是否值得付出努力,因为我想学习比这更有效的方法.谢谢大家.